View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Barb Reinhardt Barb Reinhardt is offline
external usenet poster
 
Posts: 3,355
Default Removing spaces from value using VBA

The value in this cell is something like "Company Name" and I need to change
it either to "CompanyName" or "Company_Name". It's printing what's there,
but range names can't have spaces and I need to remove them. I'd like to
know how I use the SUBSTITUTE function with this

rangename = Workbooks(curbook).Worksheets(datasheet).Range("a" & i).Value

So that "Company Name" can be converted to "Company_Name".

"OZDOC" wrote:

Range("a" & i).Value

I am guessing this is where the name comes from so this reference cell can
youshow me what you have in it ? formula ?



"Barb Reinhardt" wrote in message
...
Trim leaves ONE space. I'd like to use the SUBSTITUTE function, but am
not
sure how to add it to what I have. Suggestions?

Thanks,
Barb Reinhardt

"OZDOC" wrote:

look at the trim function it may help

"Barb Reinhardt" wrote in
message
...
I need to define a value for rangename. I have this working so far:

rangename = Workbooks(curbook).Worksheets(datasheet).Range("a" &
i).Value
Debug.Print rangename

Unfortunately, the range name has SPACES in it and when I use it to
create
a
named range, it GACKS. How do I remove the spaces from this?

Thanks,
Barb Reinhardt