Return the address of a specific column in named range

Godfather

New Member
Joined
Jul 2, 2007
Messages
7
I am trying to write some VBA to return the address of a specific column in a named range in my worksheet. For example, right now I am using the following code to return the whole range address of $I$66:$J$75, but I only want $I$66 to show. Could anyone please help me on this?

Function NamedRangeAddress(NamedRange As Range)

NamedRangeAddress = Range(NamedRange).Address

End Function

Thanks!
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
I can't get the function you posted to work, but if you want the first cell of a named range:

Code:
Function NamedRangeAddress(NamedRange As Range)
    NamedRangeAddress = NamedRange.Cells(1, 1).Address
End Function
 
Upvote 0
Maybe I need to be a bit clearer on what my function was doing. It was looking inside the cell "NamedRange" to read the contents and return the address of the name of the range which is located inside the cell "NamedRange." However, I need the address of only the first column because I am trying to use the range address the funciton returns to create a data validation list.

Thanks!
 
Upvote 0
Nevermind, I just figured it out. I used the following code:

Function NamedRangeAddress(NamedRange As Range)

NamedRangeAddress = Range(NamedRange).Columns("A").Address

End Function

Thanks :)
 
Upvote 0
Oh I see. If the name Temp refers to I66:J75 and A1 contains the text Temp, try:

=NamedRangeAddress(A1)

with:

Code:
Function NamedRangeAddress(NamedRange As Range)
    NamedRangeAddress = Range(NamedRange).Cells(1, 1).Address
End Function
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,816
Members
449,049
Latest member
cybersurfer5000

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