除了我之前的问题,我已经定义了几个范围,
例如:
Sheets(“Customers”).Activate
Set MYR1 = Range(Cells(1, 1), Cells(1, 25))
Set MYR2 = Range(Cells(5, 1), Cells(5, 25))
Set MYR2 = Range(Cells(16, 1), Cells(16, 25))
我还设置了以下子例程
Sub Findany(rngToSearchIn As Range)
Set foundrange = rngToSearchIn.Find(what:=i)
If foundrange Is Nothing Then
Do Something
Else
Do Something Else
End If
End Sub
我现在的问题是,每次调用Findany子例程时,如何让调用子例程更新范围名称
例如
Call Findany(MYR1)
Call Findany((MYR2)
答案 0 :(得分:1)
Dim arr(1 to 3) As Range, i
With Sheets(“Customers”)
Set arr(1) = .Range(.Cells(1, 1), .Cells(1, 25))
Set arr(2) = .Range(.Cells(5, 1), .Cells(5, 25))
Set arr(3) = .Range(.Cells(16, 1), .Cells(16, 25))
End With
For i = 1 to 3
Findany arr(i)
Next i