Extract numbers from string

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,074
Office Version
  1. 2019
Platform
  1. Windows
Label1 = Price: $0.00/yr

How can I extract "$0.00" from a label. I've tried Split(label1, "/") (0), but it returns "Price: $0.00"
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Label1 = Price: $0.00/yr

How can I extract "$0.00" from a label. I've tried Split(label1, "/") (0), but it returns "Price: $0.00"
Do they all follow this exact same format?
Please post a larger sample size showing the various different ways the data might look.

Also, are you trying to do this in an Excel formula or in VBA?
 
Upvote 0
Do they all follow this exact same format?
Please post a larger sample size showing the various different ways the data might look.

Also, are you trying to do this in an Excel formula or in VBA?


1. Yes..I only want the price e.g. 1.99
2. VBA only
 
Upvote 0
I tried the code below but can get the cents to appear

Int(Split(Replace(lbPrice, "/year", ""), "$")(1))
 
Upvote 0
For a value in "label1" like "Price: $0.00/yr", try this:
VBA Code:
    Dim arr1() As String
    Dim arr2() As String
    
    arr1 = Split(label1, "$")
    arr2 = Split(arr1(1), "/")
    
    MsgBox arr2(0)
 
Upvote 1
Solution
Thank you Joe for your assistance and expertise :)

BTW...I modified it to...

VBA Code:
Split(Split(Label1, "$")(1), "/")(0)
 
Upvote 0
Thank you Joe for your assistance and expertise :)

BTW...I modified it to...

VBA Code:
Split(Split(Label1, "$")(1), "/")(0)
You are welcome.
Glad I was able to help.

Yep, you can combine it all to one line.
I often like to break it up over multiple lines for demonstration purposes so it can be more easily seen how it is working (sometimes it can be confusing, especially on longer formulas when everything is together on one long line).
 
Upvote 0

Forum statistics

Threads
1,215,262
Messages
6,123,950
Members
449,134
Latest member
NickWBA

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