cboshdave
cboshdave

Reputation: 75

Working with a Range Variable...syntax

I have the following code:

Set rFinder = wkEnrollment.Range("EnrollmentIDs")  
With Range(rFinder)
    Set LastCell = .Cells(.Cells.Count)
End With

It errors when I do my With Range(rFinder) line. rFinder is dim'd as a Range. The error is:

Method 'Range' of object '_Global' failed

I am not sure of the syntax on this?

Upvotes: 0

Views: 156

Answers (1)

mechanical_meat
mechanical_meat

Reputation: 169314

Since rFinder is already a Range object you should simply use:

Set rFinder = wkEnrollment.Range("EnrollmentIDs")  
With rFinder
    Set LastCell = .Cells(.Cells.Count)
End With

Upvotes: 1

Related Questions