Link to home
Create AccountLog in
Avatar of xllvr
xllvrFlag for United States of America

asked on

Extract variable text/numbers within string in Excel

Hello Experts!

Attached is a small sample of some data I'm working with. Column E [highlighted] is the issue. I need to extract Ticket Number and Passenger Name from among the other data in those cells. I have tried a few helper columns in another file but realized quickly that the Ticket Number lengths are inconsistent. Also, the use of the term Ticket Number also appears as TKT NO. and TKT#.

I have been using variations on MID, TRIM, & FIND but can't crack the ticket length problem. Would truly appreciate any help you might give.
SOLUTION
Avatar of Alan
Alan
Flag of New Zealand image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of xllvr

ASKER

@Martin Liss - Thank you for your response and attachment. Your code is nearly perfect. Your file is attached with the areas in question highlighted in yellow. There are some instances of ticket numbers with both numbers and letters. Your code is only pulling in numbers. There are also occurrences where the passenger name isn't extracted. Last, when I use the code on my larger data set, some of the ticket numbers are displayed as like this example 5.26142E+12 but look accurate in the formula bar. I think that I might just need to use TRIM there. Will you be able to modify the code to accommodate what I've highlighted?  29092442.xlsm

@Shaun Vermaak - Thanks so much for weighing in. I am completely unfamiliar with RegEx functions but will look into it further. I'm not certain I'll be able to translate it to my specific situation with ease but am up for learning more.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of xllvr

ASKER

This is great! Thank you for making those adjustments. Very much appreciated!
You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
              Experts Exchange Top Expert VBA (current)