Vba if语句visual basic的对象必需错误
我想在VBA中设置一个代码,以识别某个范围内非数字的任何单元格,例如NUM!并将其替换为一条语句。对于包含数字的所有单元格,我希望保留该数字的值 我的代码是Vba if语句visual basic的对象必需错误,vba,Vba,我想在VBA中设置一个代码,以识别某个范围内非数字的任何单元格,例如NUM!并将其替换为一条语句。对于包含数字的所有单元格,我希望保留该数字的值 我的代码是 Sub convert_cell() Dim c As range For Each c In ActiveCell.CurrentRegion.Cells If c Is Number Then c.Value = c.Value Else: c = "no ROI"
Sub convert_cell()
Dim c As range
For Each c In ActiveCell.CurrentRegion.Cells
If c Is Number Then
c.Value = c.Value
Else: c = "no ROI"
End If
Next c
End Sub
但是,我得到消息:运行时错误424。需要对象。请尝试以下代码:
Sub convert_cell()
Dim c As Range
For Each c In ActiveCell.CurrentRegion
If IsNumeric(c) Then
c.Value = c.Value
Else: c = "no ROI"
End If
Next c
End Sub
c是一个对象吗?很久以前我用过vba@bestprogrammerintheworld是的,c被定义为范围