Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting substrings of varying size

Status
Not open for further replies.

watercooler

Programmer
May 7, 2004
13
0
0
CA
I have inherited an abundance of Excel files that had some sloppy data input. Here is an example:

BBR 689.5 - 690.5 683.0 - 684.0 673.0 - 678.0
LUF1 653.0 - 654.5
LUF2 632.5 - 636.0
MUF1 621.5 - 623.0
MUF2 591.5 - 593.0 589.0 - 590.0

Column A contains the zone name and column B contains the zone intervals. If a zone contains more than 1 zone interval it is separated by at least 4 spaces. I can't figure out how to extract it so there is only 1 zone interval per a line, like so:

BBR 689.5 690.5
BBR 683 684
BBR 673 678
LUF1 653 645.5
LUF2 632.5 636
MUF1 621.5 623
MUF2 591.5 593
MUF2 589 590

Can anyone please help me?
 
Check Split:
Code:
Dim str
str = Split("689.5 - 690.5          683.0 - 684.0          673.0 - 678.0", "   ")  '4 spaces

That will give you an array of 3 elements:

str(0) = "689.5 - 690.5"
str(1) = "683.0 - 684.0"
str(2) = "673.0 - 678.0"

HTH

---- Andy
 
Awesome - thanks Andrzejek!

How many does an "abundance" make?...about 1800 different Excel files. So needless to say this will save me a ton of time cleaning the data before I build a database for it.

Thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top