Help on Extracting numbers from a comma-delimited list in excel

wangzic3

New Member
Joined
Feb 24, 2019
Messages
1
I am trying to extract numbers from a comma delimited list using excel function/or VBA code
The data looks like this:
1,55,,Private Information #1 for UB,After 56 seconds, your private estimate is that the final value will be $51.19
If the above data are in cell A1, I want to retrieve UB in cell B1 and 56 in cell C1 and 51.19 in cell D1. So, only the last characters in 3rd filed and only numbers in the 5th and 6th comma-separated field are needed, and there will only be one number in the 5th and 6th field. For the 5th segment, the # will always be surrounded by the same text( i.e., After xxx seconds). For the 6th segment, it will always be the final characters, and they always follow a single $
I am not familiar with excel and would appreciate any help! Thanks in advance.
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Based on your string in "A1" (noting your string have 2 commas together near the start) then try this for results in Range("B1:D1")
Code:
[COLOR="Navy"]Sub[/COLOR] MG24Feb42
[COLOR="Navy"]Dim[/COLOR] Sp [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] s [COLOR="Navy"]As[/COLOR] Variant
Sp = Split(Range("A1"), ",")
[COLOR="Navy"]For[/COLOR] n = 0 To UBound(Sp)
   [COLOR="Navy"]Select[/COLOR] [COLOR="Navy"]Case[/COLOR] n
        [COLOR="Navy"]Case[/COLOR] [COLOR="Navy"]Is[/COLOR] = 3: s = Split(Sp(n), " "): [B1] = s(UBound(s))
        [COLOR="Navy"]Case[/COLOR] [COLOR="Navy"]Is[/COLOR] = 4: s = Split(Sp(n), " ")
            [COLOR="Navy"]For[/COLOR] c = 0 To UBound(s)
                [COLOR="Navy"]If[/COLOR] IsNumeric(s(c)) [COLOR="Navy"]Then[/COLOR] [C1] = s(c)
            [COLOR="Navy"]Next[/COLOR] c
        [COLOR="Navy"]Case[/COLOR] [COLOR="Navy"]Is[/COLOR] = 5: s = Split(Sp(n), " "): [D1] = s(UBound(s))
    [COLOR="Navy"]End[/COLOR] Select
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 

jtakw

Well-known Member
Joined
Jun 29, 2014
Messages
5,146
Hi,

Your count/descriptions of commas do Not match your sample.
Also, there's No space after the comma ( UB,After ) and before "After", there are no spaces in between the 1st 3 commas and letters, might there be ?

Please show a few more possible samples and an accurate description.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,041
Messages
5,526,417
Members
409,701
Latest member
nitmani

This Week's Hot Topics

Top