0
votes

I have some VBA code that works on named ranges that are set up externally. How can I get the actual cell reference from this range? For example

Dim rangeID As String
rangeID = ActiveSheet.Range("MyNamedRange").UnknownFunction

Sets rangeID to "CG13" if the named range "MyNamedRange" refers to CG13

1

1 Answers

1
votes

ActiveSheet.Range("MyNamedRange") already is the "actual cell reference." It references the cell object. You should directly use that object reference anywhere you need a cell in your code.

The textual representation of the address of that cell is ActiveSheet.Range("MyNamedRange").Address. You can provide parameters to get the address in the form you want (e.g. to get "CG13" you call Address(False, False, xlA1)).