indirect in VBA

doug stoyer 1 Reputation point
2021-11-05T15:58:52.91+00:00

I'm using the indirect function in a range.select statement in VBA for excel:

Range("lookupref").Select

Where lookupref is a string that evaluates (for testing purposes) to B2

[I'm using a msgBox to show me what the value is]

I keep getting an error :

Run-time error '1004':
Method 'Range' of object '_global' failed

not sure what this means - I'm fairly new to VBA and working through errors as they arise, but this one has me stumped. Any suggestions?

Microsoft 365 and Office Development Other
Developer technologies Visual Basic for Applications
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 122.6K Reputation points
    2021-11-05T16:52:50.967+00:00

    Try Range(lookupref) instead of Range("lookupref").

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.