Cell address to another cell in a named range

most

Board Regular
Joined
Feb 22, 2011
Messages
106
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
  2. Mobile
I would to get a cell address from a named range which contains the address in text format. Searched but only get none related hits, any suggestion how I could solve this?

Excel Formula:
Sheet ONE cell A1 = "Sheets("TWO").Range("B2")"
Sheet TWO cell B2 = 1000

ANamedRange =ONE!$A$1 (Name manager)

VBA Code:
debug.print ANamedRange.value

Expected result: 1000

Why? I want to make a sheet with "parameters" with reference to correct cells needed for my code, so if the layout change I only need to change the parameter sheet.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hmm can't think f a way of doing it without pulling the value in A1 apart, see below:
VBA Code:
Sub ReturnAddress()
    Dim str As String, rng As Range
    Dim sSht As String, sRng As String

    str = Range("ANamedRange").Value ' value from named range
    sSht = Split(Split(str, ".")(0), """")(1) ' get sheet part
    sRng = Split(Split(str, ".")(1), """")(1) ' get address part
    Set rng = Sheets(sSht).Range(sRng) ' create a range from the above created strings
    
    Debug.Print rng.Value ' ask for rng value
End Sub
 
Upvote 0
Another similar option:
VBA Code:
Sub ReturnAddress()
    Dim str As String
    Dim sSht As String, sRng As String

    str = Range("ANamedRange").Value ' value from named range
    sSht = Split(Split(str, ".")(0), """")(1) ' get sheet part
    sRng = Split(Split(str, ".")(1), """")(1) ' get address part
   
    Debug.Print Evaluate("'" & sSht & "'!" & sRng)
End Sub
 
Upvote 0
Hi, why wouldn't you just assign the actual range you want to the named range rather than to a cell that contains the address of the range you want, which seems a tad convoluted.
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,014
Members
449,280
Latest member
Miahr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top