View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default adding named ranges without a "-"

Dim myStr As String
myStr = "Ju-Li"
'xl2k or higher
myStr = Replace(myStr, "-", "_")
'or before xl2k
'myStr = Application.Substitute(myStr, "-", "_")
MsgBox myStr


For just that one problem.


mark kubicki wrote:

I'm writing a sub that works thru a worksheet adding named ranges for all of
the values in a given column (the values are person's names); and I am
naming these "named ranges" effectively the same as the person's name
(ex: the person's name might be "Tom", so the range is named
"Proj_mngr_Tom")

one of the values person's name has a "-" (Ju-Li) which is causing an
error...

is there away of stripping the "-"? (I am presuming I'll need to write a
sub that cycles thru each letter, checking its value...)

thank in advance
-mark


--

Dave Peterson