Is there a better way to extract data from a string?

HockeyDiablo

Board Regular
Joined
Apr 1, 2016
Messages
182
I am trying to extract random pricing data within a string. I have about 50 set prices for items within the string. Wondering if one of you excel geniuses on here can think of an easy solution? Here is the method I have came up with. Any ideas are welcome.



ABCDE
DescriptionLeft 10 CharsNumber ExtractedRight 10 Chars
1Steel White $599 Sears Craftsman Trolley 22 198 galv rollers Total $815eel White599 Sears Cra
25 yr Sp $130.00 cables 38 Keyless entry FREE LM Belt Drive 10yr War. $349.00 517 Total on CC5 yr Sp $130 cables 38

<tbody>
</tbody>
 
Last edited:
Re: Extract each set of numbers to a column?

My oversight, I gave you the wrong set of instructions for installation of the code.

Delete the code from the sheet (right-click the sheet tab and select View Code to get to it). Then follow these steps:

To install the code:
1. With your workbook active press Alt and F11 keys. This will open the VBE window.
2. In the project tree on the left of the VBE window, find your project and click on it.
3. On the VBE menu: Insert>Module
4. Copy the code from your browser window and paste it into the white space in the VBE window.
5. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
6. Press Alt+F8 keys to run the code
7. Make sure you have enabled macros whenever you open the file or the code will not run.


It does work now. Nice work
 
Upvote 0

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Re: Extract each set of numbers to a column?

I initially had it there when I originally tested and received null results. ALT+F8 doesnt even bring up the function labelled [ExtractNumsToCells]
What do you mean by "null" results. What did you see in the cells that the formula was in?
 
Upvote 0
Re: Extract each set of numbers to a column?

Thanks for the nice words, but you are being far too kind... there is lots that I cannot figure out, you just don't see me post in response to them.:LOL:

You're quite welcome, you have came through for me quite a few times and for that I thank you.
 
Upvote 0
Re: Extract each set of numbers to a column?

OK - ignore post #22 which was posted before I saw this. Glad you got it working.


no worries, thanks for the leg work. This stuff is as complicated as it is entertaining. Thanks again
 
Upvote 0
Re: Extract each set of numbers to a column?

Thanks for the nice words, but you are being far too kind... there is lots that I cannot figure out, you just don't see me post in response to them.:LOL:


What characters would create a type mismatch? I tried to debug and locate where the mismatch was and having no luck.

I copy and paste sections of the data and it works great. But when I run the full 97k rows, I get the mismatch
 
Upvote 0
Re: Extract each set of numbers to a column?

I was thinking about this UDF:

Code:
Function F_snb(c00)
    F_snb = ""

    If c00 <> "" Then
       st = Split(c00)
       For j = 0 To UBound(st)
          If Val(Replace(st(j), "$", "")) = 0 Then st(j) = ""
       Next
       F_snb = Join(st)
    End If
End Function
or
Code:
Function F_snb(c00)
    F_snb = ""
    
    If c00 <> "" Then
       st = Split(Replace(c00, "$", ""))
       For j = 0 To UBound(st)
          If Val(st(j)) = 0 Then st(j) = "~"
       Next
       F_snb = Join(Filter(st, "~", 0))
    End If
End Function
 
Last edited:
Upvote 0
Re: Extract each set of numbers to a column?

What characters would create a type mismatch? I tried to debug and locate where the mismatch was and having no luck.

I copy and paste sections of the data and it works great. But when I run the full 97k rows, I get the mismatch


found it, dang #NAME? error I didnt catch
 
Upvote 0

Forum statistics

Threads
1,214,974
Messages
6,122,536
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top