ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   range names (https://www.excelbanter.com/excel-programming/381725-range-names.html)

Zaahir

range names
 
Hi

y does the code......
selection.name=range("A1").text
return an error....

"this name is not valid"
please help!!!!!!!!!!!!

John Coleman

range names
 
Because - the name is not valid. As an experiment I created a
spreadsheet with the text "Bob" in A1 then wrote a sub with your line
of code and it executed with no problem at all - so the problem must
lie with the actual text in A1. I think that the rules are that it
shouldn't have anything other than letters, underscores and numbers,
shouldn't be confusable with a cell address and shouldn't start with a
number. What do you have in A1?

Zaahir wrote:
Hi

y does the code......
selection.name=range("A1").text
return an error....

"this name is not valid"
please help!!!!!!!!!!!!



John Coleman

range names
 
One more thought - note that when you use Insert - Names - Create to
create a name, Excel automatically replaces spaces with underscores.
You can do this in VBA:

Selection.Name = Replace(Trim(Range("A1").Text), " ", "_")

HTH

-John Coleman

John Coleman wrote:
Because - the name is not valid. As an experiment I created a
spreadsheet with the text "Bob" in A1 then wrote a sub with your line
of code and it executed with no problem at all - so the problem must
lie with the actual text in A1. I think that the rules are that it
shouldn't have anything other than letters, underscores and numbers,
shouldn't be confusable with a cell address and shouldn't start with a
number. What do you have in A1?

Zaahir wrote:
Hi

y does the code......
selection.name=range("A1").text
return an error....

"this name is not valid"
please help!!!!!!!!!!!!




All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com