Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get a Range to return its Name?

Dim sampleRange as Range
Set sampleRange = Worksheet.Range(Cells(1,1),Cells(1,4)
sampleRange.Name = "Range1"
MsgBox sampleRange.Name

The above code will show the actual address of the range, not the name. Why?
How do I get a named range to return its name?

like image 778
GenericJam Avatar asked Sep 02 '10 19:09

GenericJam


People also ask

How do you show named ranges in Excel?

You can find a named range by using the Go To feature—which navigates to any named range throughout the entire workbook. You can find a named range by going to the Home tab, clicking Find & Select, and then Go To. Or, press Ctrl+G on your keyboard. In the Go to box, double-click the named range you want to find.

How do you display named ranges?

To display a named range on another sheet, you just need to use the formula =name (the range name) and press Shift + Ctrl + Enter keys together.

How do you name a range in an equation?

Select the range you want to name, including the row or column labels. Select Formulas > Create from Selection. In the Create Names from Selection dialog box, designate the location that contains the labels by selecting the Top row,Left column, Bottom row, or Right column check box. Select OK.


1 Answers

For a Range, Name isn't a string it's a Name object, that you then take the Name property of to get the string:

MsgBox sampleRange.Name.Name
like image 89
Lance Roberts Avatar answered Sep 30 '22 17:09

Lance Roberts