0

当我对 Test1 子的最后一行进行编码时出现错误。它说“期待=”。有任何想法吗?

Sub selectByUsedRows(usedCol As String, selectCol As String)
n = Range(usedCol).End(xlDown).Row
Range(selectCol & "1:" & selectCol & n).Select
End Sub

Sub Test1()
Dim a As String, b As String
a = "A"
b = "B"
selectByUsedRows (a, b)
End Sub

来自评论的更正代码,谢谢!

Sub selectByUsedRows(usedCol As String, selectCol As String)
n = Range(usedCol & "1").End(xlDown).Row
Range(selectCol & "1:" & selectCol & n).Select
End Sub

Sub Test1()
Dim a As String, b As String
a = "A"
b = "B"
selectByUsedRows a, b
End Sub
4

1 回答 1

3

你打电话selectByUsedRows就像你在调用一个函数。调用子例程时不需要括号:

selectByUsedRows a, b
于 2012-09-18T13:17:50.350 回答