我在网上为我的问题寻找解决方案,但找不到。在运行以下代码时,我会得到错误:第二行的外部过程无效。有谁有解决这个问题的建议吗?谢谢。
Dim i As Integer
For i = 1 To 37918
If Sheets("nw").Cells(i, 1).Value = Cells(6, 3).Value And Sheets("nw").Celss(i, 2) > Sheets("nw").Cells(i, 2).Value Then Sheets("nw").Cells(15, 22).Value = Sheets("nw").Cells(i, 3).Value
End If
Next i
End Sub
Sub NewCost()
End Sub另外,当我将Sub NewCost()放在Dim i as integer之上时,我会得到以下错误:
如果没有阻塞,则结束
发布于 2015-06-24 20:33:20
For循环位于Sub()之外。
试试这个:
Option Explicit
Sub NewCost()
Dim i As Long
For i = 1 To 37918
With Sheets("nw")
If .Cells(i, 1) = .Cells(6, 3) And .Celss(i, 2) > .Cells(i, 2) Then
.Cells(15, 22) = .Cells(i, 3)
End If
End With
Next
End Sub发布于 2015-06-24 20:28:50
整数的最大值为32767。如果你想让你的计数器高那么高,你必须选择一种不同的数据类型(也许很长?)
https://stackoverflow.com/questions/31036314
复制相似问题