现在我正在尝试使用某一行中三个不同单元格的信息,使用我想要的信息自动填充另一个单元格。自从我使用VBA以来已经有一段时间了,我不知道为什么我会得到"对象定义错误"。这是我的代码,如果你能帮我指出正确的方向,我会很感激。
Sub Conduit()
Sheets("Sheet4").Select
Dim celltxt As String
Dim celltxt2 As String
Dim celltxt3 As String
Dim i As Integer
i = 3
Do While Cells(i, 3).Value <> ""
celltxt = ActiveSheet.Range("Bi").Text
celltxt2 = ActiveSheet.Range("Fi").Text
celltxt3 = ActiveSheet.Range("Di").Text
If InStr(3, celltxt, "RMS") And InStr(3, celltxt2, "XHHW-2") And InStr(3, celltxt3, "1/C") Then
[Ai].Value = "2"
Else
[Ai].Value = "999999"
End If
i = i + 1
Loop
End Sub
答案 0 :(得分:2)
这一行
celltxt = ActiveSheet.Range("Bi").Text
不正确。
尝试
celltxt = ActiveSheet.cells(i,2).Text
同样的艾。你不能在字符串中使用intvar并期望它是正确的。