Extract first numerical value to the left & right of a defined criteria from a string of text

HockeyDiablo

Board Regular
Joined
Apr 1, 2016
Messages
182
A
110 yr spring 399 rollers 188 sc 40 total 627 ck
2sc $40 radio board $140 spring $103.80 total $283.80 ck
3same day 5 yr 299 cables 58 rollers 148 sc 40 545

<tbody>
</tbody>

Above are a few samples strings from Microsoft Excel that I need the extraction from, respectively in cells "A1", "A2", "A3"...

I have several items in the string and need to extract the pricing, but it could be to the left or the right and wont always carry a $ sign.

Example: I would like to select "sc" as the defined criteria and return the first numerical value to the left and right


Return: something like this

B
1188, 40
2, 40
3148, 40

<tbody>
</tbody>

I could work with values in "B" and "C"
 
Last edited:
Runtime Error '9' Script out of range

Code:
Result(R, 1) = Result(R, 1) & ", " & Split(Trim(SC(1)))(0)

But it works when I use other data? Would a certain character throw this off??
That probably means you have the letters "sc" at the end of the text with no number following it. Change the line of code you posted to this (I marked the change in red) and see if it works correctly afterwards...

Result(R, 1) = Result(R, 1) & ", " & Split(Trim(SC(1)) & " ")(0)
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
That did it, but I am getting some alpha to return:

"alex trolley was disco'ed pitched struts and told her needed new springs to compensate for added weight. $399 10 year spring $129 strut $129 strut $40 sc total$697ck" Returns 40, total697ck

" having issues with light sockets again is using 100 watt lightbulbs recommended going down to 60 and trying rough sc bulbs would still like is to check it out ~vnl chris told him to stop using 100 watt bulbs the socket still worked but it was touchy. went over bb's and cables again still no go." Returns rough, bulbs
 
Last edited:
Upvote 0
That did it, but I am getting some alpha to return:

"alex trolley was disco'ed pitched struts and told her needed new springs to compensate for added weight. $399 10 year spring $129 strut $129 strut $40 sc total$697ck" Returns 40, total697ck

" having issues with light sockets again is using 100 watt lightbulbs recommended going down to 60 and trying rough sc bulbs would still like is to check it out ~vnl chris told him to stop using 100 watt bulbs the socket still worked but it was touchy. went over bb's and cables again still no go." Returns rough, bulbs
What should the answers be for the above two examples?
 
Upvote 0
Well come to think of it nothing.... if both equal alpha then Service Call "sc" charge would be 0$ and I can write that.

Its always my data. Thank you again sir.

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

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