Excel vb 运行时总是提示:运行时错误‘13’,类型不匹配
提示这句错了:Fori="10909117叶丽雅"To"12928214王力航"Sub输入数据()Sheet1.Range("A1").Value="12928214王力...
提示这句错了: For i = "10909117 叶丽雅" To "12928214 王力航"
Sub 输入数据()
Sheet1.Range("A1").Value = "12928214 王力航"
For i = "10909117 叶丽雅" To "12928214 王力航"
t = "a" & i
Sheet1.Range(t).Value = i
Next i
End Sub
Sub 改变数据()
Dim i As Integer
Dim j As Integer
Dim b As String, t As String
j = 2
b = "b"
For i = "10909117 叶丽雅" To "12928214 王力航"
If i Mod 4 = 0 Then
j = j + 1
b = "b"
End If
t = "a" & i
b = Chr(Asc(b) + 1)
Sheet1.Range(b & j).Value = Sheet1.Range(t).Value
Next i
End Sub 展开
Sub 输入数据()
Sheet1.Range("A1").Value = "12928214 王力航"
For i = "10909117 叶丽雅" To "12928214 王力航"
t = "a" & i
Sheet1.Range(t).Value = i
Next i
End Sub
Sub 改变数据()
Dim i As Integer
Dim j As Integer
Dim b As String, t As String
j = 2
b = "b"
For i = "10909117 叶丽雅" To "12928214 王力航"
If i Mod 4 = 0 Then
j = j + 1
b = "b"
End If
t = "a" & i
b = Chr(Asc(b) + 1)
Sheet1.Range(b & j).Value = Sheet1.Range(t).Value
Next i
End Sub 展开
4个回答
展开全部
For i = "10909117 叶丽雅" To "12928214 王力航",i作为循环变量,应该为一个数值才对,而你却给了它一个字符串,
你是想从 "10909117 叶丽雅" 单元格,循环到"12928214 王力航" 单元格吧,你可以这样,假如第一个单元格行号为10,第二个单元格行号为50,那你这样写,就可以了
For i=10 To 50
你是想从 "10909117 叶丽雅" 单元格,循环到"12928214 王力航" 单元格吧,你可以这样,假如第一个单元格行号为10,第二个单元格行号为50,那你这样写,就可以了
For i=10 To 50
更多追问追答
追答
你是想让横列转置呀,你先把数据复制一下,然后放到一个空白处,选择性粘贴中选择转置就可以了
展开全部
作为循环变量的i应该是整数。你用的是字符,所以是不正确的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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 王力航"
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 王力航"
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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 王力航"
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 王力航"
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询