ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Wildcard pattern matching and replace in string (https://www.excelbanter.com/excel-programming/273864-wildcard-pattern-matching-replace-string.html)

Janelle

Wildcard pattern matching and replace in string
 
Well, having spent pretty much all day on this "little"
project that sounded so easy originally, I finally found
RegExp & its wonderful pattern-matching capabilities. And
I finally found enough help on the topic to put something
together that works, even if I'm not completely sure how.


-----Original Message-----
Ok, here's a "fun" one...
Running Excel 97.

I have 2 files. The first file is a 12,000 line

partsbook
that has a bunch of old numbers in it that need to be
replaced. The second file is a list of over 7,000 old
numbers and the new ones that replace them.

The partsbook is actually a text file, but I've also
imported it into Excel, so I could use either format for
this. The first problem is that each line is 558
characters long. The second problem is that there's
really no good way to split it into columns, since there
are multiple line types and each type has a different
arrangement.

My first thought was to loop through the replacement

list,
searching each line of the partsbook for each number in
the list. It would work fabulously if I had a couple
extra years and a spare computer....

The old part numbers are in the format #.###.####.# or
##############
What I'd like to do is search each line of the partsbook
for anything that matches those patterns, then do a

simple
lookup to find the replacement number and replace the old
number with the new number. But I can't figure out how

to
do a pattern matching search AND capture the resulting
string AND replace it.

Any ideas?
.



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com