Excel vb 运行时总是提示:运行时错误‘13’,类型不匹配

2024-12-03 23:32:34
推荐回答(4个)
回答(1):

For i = "10909117 叶丽雅" To "12928214 王力航",i作为循环变量,应该为一个数值才对,而你却给了它一个字符串,
你是想从 "10909117 叶丽雅" 单元格,循环到"12928214 王力航" 单元格吧,你可以这样,假如第一个单元格行号为10,第二个单元格行号为50,那你这样写,就可以了
For i=10 To 50

回答(2):

作为循环变量的i应该是整数。你用的是字符,所以是不正确的。

回答(3):

Sub tess()
Dim a As Boolean
Dim b As Boolean
a = True
b = True
aa = 1
bb = 1
While a
If "10909117 叶丽雅" = Cells(aa, 1).Value Then
a = False
End If
aa = aa + 1
Wend
While b
If "12928214 王力航" = Cells(bb, 1).Value Then
b = False
End If
bb = bb + 1
Wend
For x = aa - 1 To bb - 1

Next
End Sub

没有做容错

For x = aa - 1 To bb - 1
即你那里面出错的 For i = "10909117 叶丽雅" To "12928214 王力航"

回答(4):

Sub tess()
Dim a As Boolean
Dim b As Boolean
a = True
b = True
aa = 1
bb = 1
While a
If "10909117 叶丽雅" = Cells(aa, 1).Value Then
a = False
End If
aa = aa + 1
Wend
While b
If "12928214 王力航" = Cells(bb, 1).Value Then
b = False
End If
bb = bb + 1
Wend
For x = aa - 1 To bb - 1

Next
End Sub

没有做容错

For x = aa - 1 To bb - 1
即你那里面出错的 For i = "10909117 叶丽雅" To "12928214 王力航"