LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How to read part of a text string only?

As a side note, it doesn't have to be the same number of characters to use
the left, right, and mid functions, but you would have to do a bit more
coding to find the location of the "_". The "instr" command will give you
the position of the "_" character.


"Brian K. Sheperd" wrote in message
...
Is it always going to be the same number of characters? You could use the
left$, mid$, and right$ functions.
varstring = "xxxx_yy_zzzzzz"
varx = left$(varstring,4)
vary = mid$(varstring,6,2)
varz = right$(varstring,6)

Or you can use the split command. This will split the string based on a
delimiter and store the values in an array.
vararray = split(varstring, "_")

Brian


"Ahsan" wrote in message
...
I have a string "xxxx_yy_zzzzzz". I would like to store "xxxx" as a

string
in
a variable, "yy" as a string in another variable, and "zzzzzz" as a

string
in
another variable. Is there code in visual basic for excel that would

help
me
achieve this?

Thanks

Ahsan





 
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
Selecting right part of text string Sue Compelling Excel Worksheet Functions 5 November 5th 09 07:54 PM
Delete part of a text string IanP Excel Worksheet Functions 3 April 6th 09 12:34 PM
Extract part of a text string Martin B Excel Worksheet Functions 7 January 13th 08 04:36 PM
Omitting right part of text string klysell Excel Worksheet Functions 6 January 13th 08 12:59 PM
How do I extract part of a text string Brennan Excel Discussion (Misc queries) 2 November 28th 06 07:26 PM


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

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"