How to obtain name of range with VB code

  • Thread starter Thread starter B F Cole
  • Start date Start date
B

B F Cole

I need to obtain the name of a selected range.

For example:

sColName as String

Columns(4).Select ' Select column D

sColName = ????? ' What is the syntax to return the name previously
assigned to the column?


Thanks for your usual fine response.
Bill
 
try this in the immediate window when the range is selected

in the vb editor:
control-g to make the window visible if it's not already
then enter the following and press enter
?selection.name.name
 
After highlighting (selecting a prviously named Rangename)
From the immediate window:

? Selection.name.name

returns the string name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top