0

Further to my earlier question, I have defined several ranges ,

for example:

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))

I have also set up the following sub routine

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

My problem now is how can I have the calling sub routine update the range name each time it calls the Findany sub routine

eg

Call Findany(MYR1)




Call Findany((MYR2)
0

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.