0

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

Community
  • 1
  • 1
Steztric
  • 2,832
  • 2
  • 24
  • 43

1 Answers1

1

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

Community
  • 1
  • 1
GSerg
  • 76,472
  • 17
  • 159
  • 346
  • Sorry, I am referring to "actual cell reference" as the Excel meaning of reference that you use to refer to other cells in the workbook, rather than the VBA meaning of reference meaning a variable referring to that range. But thank you, `Address` is exactly what I am looking for. – Steztric Nov 27 '13 at 11:40