我正在运行一些VBA来将整个Excel工作表切换为大写。VBA(上)类型不匹配错误
但是,它跳过,并提供类型不匹配错误,并在一半通过失败。
Sub MyUpperCase()
Application.ScreenUpdating = False
Dim cell As Range
For Each cell In Range("$A$1:" & Range("$A$1").SpecialCells(xlLastCell).Address)
If Len(cell) > 0 Then cell = UCase(cell)
Next cell
Application.ScreenUpdating = True
End Sub
我假设它被绊倒在一个特定的细胞但有数百行。有没有办法让它跳过错误
'如果Len(CStr(cell))> 0 Then cell = UCase(CStr(cell))'help's all? – bobajob
你可能有一个错误的单元格 - 你有没有试过调试你的代码来查看哪条线路导致错误?简单地忽略错误就是不好的做法。 –
数字可能会把它搞砸。基本的错误处理应该解决这个问题:) –