我有一个如下所示的代码: - ))
答案 0 :(得分:0)
与QHarr建议的一样,使用--build
通常是一个好主意,并尽量不要将VBA运算符用作变量。
另外,当处理超过1张时,最好在代码中定义每个。我不知道你的第一张纸是什么,所以请更改一行:设置gcc
以适应:
Option Explicit
答案 1 :(得分:0)
我对你所写的内容的理解是你想要这样的东西。
Option Explicit
Sub Test()
' Unqualified book/sheet below, means code will always run the isnumeric check on the cells of the active sheet. Is that what you want? '
Dim LastRow As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Dim Index as long
Dim i As Long
Dim NonNumericRows() as string
Redim NonNumericRows(1 to lastrow)
For i = 2 To LastRow
If not(IsNumeric(Range("A" & i).Value)) Then
Index = index + 1
NonNumericRows(Index) = cstr(i)
End if
Next i
Redim preserve NonNumericRows(1 to index)
Sheets("Error").Range("A1").Value = "Error in row(s): " & strings.join(nonnumericrows,", ") & " of ColumnNAme"
End Sub
希望它有效或有帮助。