View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_2369_] Rick Rothstein \(MVP - VB\)[_2369_] is offline
external usenet poster
 
Posts: 1
Default Trimming worksheet name from an imported data source

If you want to "trim off" the first 12 characters from your worksheet name,
you can use the Mid function to do that. Normally, you would specify a 3rd
argument to this function telling it how many characters to retrieve from
the starting point (specified in the 2nd argument) onward; however, if you
omit the 3rd argument, the Mid function will retrieve from the starting
point to the end of the text. So, if...

WorksheetName = "JA_20082008_CHRYSLER_300_SERIES"

then...

TrimmedWorksheetName = Mid(WorksheetName, 13)

Does that help?

Rick


"lonnierudd via OfficeKB.com" <u11209@uwe wrote in message
news:8795f09169ce2@uwe...
The database I'm pulling the worksheet from comes from a vendor, and it
automatically assigns the worksheet name. What I'm looking for is to be
able
to have a macro pull the new numbers each month after I've loaded the new
tables. There are 80+ different vehicles I pull this information on, so
unless we can get the vendor to give us the data with a consistent name,
not
likely, then I need to be able to put it into a consistent form so that
the
worksheets with all the calculations on them will update correctly when
the
tables themselves are updated. Does that help? So if it'll trim 12
characters
off the left side of the worksheet name, then I'd be good. I'd just repeat
that on all 80+ worksheets that I need to trim. Trimming from the right
would
mean different code for each page since there's lots of different types of
vehicles.


Rick Rothstein (MVP - VB) wrote:
I'm not totally clear on what you are asking. Do you want to know how to
change the first 2 characters of a string of text? If your string is in a
variable named, say, TabName so that currently,

TabName = "JA_20082008_CHRYSLER_300_SERIES"

and you want to change this to start with AS, then there are two ways you
can do this...

1) TabName = "AS" & Mid(TabName, 3)

2) Mid$(TabName, 2) = "AS"

You could then assign the TabName back to the tab. If you are asking
something else, them I think you will have to provide us with more
details.

Rick

I'm bringing in data from an external source that changes each month,
and
to

[quoted text clipped - 9 lines]
Next month the JA will be replaced with AS for August/September. I
really
would appreciate your help.


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200807/1