在excel vba 中,类型不匹配,怎么解决?
Sub生成新表()DimiAsLong,nAsLongDimxAsLongForn=1ToSheet1.Range("b1").End(xlToRight).Column...
Sub 生成新表()
Dim i As Long, n As Long
Dim x As Long
For n = 1 To Sheet1.Range("b1").End(xlToRight).Column
For i = 2 To Sheet1.Range("a65536").End(xlUp).Row
If Sheet1.Range("f" & i) <> "#N/A" Then 此行提示类型不匹配,用not like 也不行
x = x + 1
Sheet3.Cells(x + 1, n) = Sheet1.Cells(i, n)
End If
Next i
x = 0
Next n
End Sub 展开
Dim i As Long, n As Long
Dim x As Long
For n = 1 To Sheet1.Range("b1").End(xlToRight).Column
For i = 2 To Sheet1.Range("a65536").End(xlUp).Row
If Sheet1.Range("f" & i) <> "#N/A" Then 此行提示类型不匹配,用not like 也不行
x = x + 1
Sheet3.Cells(x + 1, n) = Sheet1.Cells(i, n)
End If
Next i
x = 0
Next n
End Sub 展开
2个回答
展开全部
Sub 生成新表()
Dim i As Long, n As Long
Dim x As Long
For n = 1 To Sheet1.Range("b1").End(xlToRight).Column
For i = 2 To Sheet1.Range("a65536").End(xlUp).Row
If not(IsError(Sheet1.Range("f" & i))) Then ' <> "#N/A" Then '此行提示类型不匹配,用not like 也不行
x = x + 1
Sheet3.Cells(x + 1, n) = Sheet1.Cells(i, n)
End If
Next i
x = 0
Next n
End Sub
Dim i As Long, n As Long
Dim x As Long
For n = 1 To Sheet1.Range("b1").End(xlToRight).Column
For i = 2 To Sheet1.Range("a65536").End(xlUp).Row
If not(IsError(Sheet1.Range("f" & i))) Then ' <> "#N/A" Then '此行提示类型不匹配,用not like 也不行
x = x + 1
Sheet3.Cells(x + 1, n) = Sheet1.Cells(i, n)
End If
Next i
x = 0
Next n
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询