WJA
WJA

Reputation: 7004

Worksheet cell custom names access value in VBA

Lets say I have a cell C1 and I define the name of it as follows below: enter image description here

How can I access this cell in VBA?

Upvotes: 1

Views: 191

Answers (2)

Emanuel Sousa
Emanuel Sousa

Reputation: 46

To access it simply write:

Range("act_sec_field").Select

For more information on this you can visit: https://msdn.microsoft.com/en-us/library/office/ff823060.aspx

Upvotes: 1

David Zemens
David Zemens

Reputation: 53623

A Name which refers to a Range (a Cell is a Range) can be accessed by name:

MsgBox Range("asc_set_field").Value

If the Name is scoped to the Workbook (default), the above should work. If it is scoped to the Worksheet, you'll need to refer also to the worksheet:

Dim ws as Worksheet
Set ws = Worksheets("sheet name") ' Modify as needed
MsgBox ws.Range("asc_set_field").Value

Upvotes: 2

Related Questions