Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Naming a Range...?

I have this change event:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.count 1 then exit sub
if not intersect(target,Range("G10:G50")) is nothing then
if Not isempty(Target) then
Target.Offset(0,1).Resize(1,4).Name =
application.substitute(Target," ","_")
end if
End if
End Sub

Is there a way to ensure that the macro can convert any name into the
name of a range?

ex. "Excavator 450 (Hitachi)", "Front-end Loader 300"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Naming a Range...?

Use application.Substitute to replace each illegal character that might be
contained.

But then is the name useful anymore?

--
Regards,
Tom Ogilvy


"mastermind" wrote:

I have this change event:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
if target.count 1 then exit sub
if not intersect(target,Range("G10:G50")) is nothing then
if Not isempty(Target) then
Target.Offset(0,1).Resize(1,4).Name =
application.substitute(Target," ","_")
end if
End if
End Sub

Is there a way to ensure that the macro can convert any name into the
name of a range?

ex. "Excavator 450 (Hitachi)", "Front-end Loader 300"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Naming a Range...?

I would like to do that, but I don't know how write it out. I got that
last little bit of code from someone on this site. I also don't know
what all the illegal characters are.

John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Naming a Range...?

Guidelines for names
What characters are allowed? The first character of a name must be a letter
or an underscore character. Remaining characters in the name can be letters,
numbers, periods, and underscore characters.

Can names be cell references? Names cannot be the same as a cell reference,
such as Z$100 or R1C1.

Can more than one word be used? Yes, but spaces are not allowed. Underscore
characters and periods may be used as word separators€” for example, Sales_Tax
or First.Quarter.

How many characters can be used? A name can contain up to 255 characters.

Note If a name defined for a range contains more than 253 characters, you
cannot select it from the Name box.

Are names case sensitive? Names can contain uppercase and lowercase letters.
Microsoft Excel does not distinguish between uppercase and lowercase
characters in names. For example, if you have created the name Sales and then
create another name called SALES in the same workbook, the second name will
replace the first one.

---------------
I guess you would have to write a set of rules to convert any string into an
acceptable name.

--
Regards,
Tom Ogilvy


"mastermind" wrote:

I would like to do that, but I don't know how write it out. I got that
last little bit of code from someone on this site. I also don't know
what all the illegal characters are.

John


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Range naming Squeaky Excel Discussion (Misc queries) 2 December 29th 06 09:10 PM
naming a range Jo[_6_] Excel Programming 2 June 24th 04 09:39 PM
naming a range Jo[_6_] Excel Programming 0 June 24th 04 07:24 PM
VB Code Naming a Range (range changes each time) krazylain Excel Programming 4 May 15th 04 12:41 PM
Naming a Range with VB Justin Excel Programming 2 December 1st 03 09:38 PM


All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"