Extracting Number only from string of text

nirvehex

Well-known Member
Joined
Jul 27, 2011
Messages
503
Office Version
  1. 365
Platform
  1. Windows
Hi,

I have a formula:
Code:
=IFERROR(IF(BJ3>Y3,M3,VLOOKUP(F3,'Bid Template'!L:CU,88,FALSE)),M3)

This returns SPEC-8 or BID-10 or SPEC-4 or BID-1.5, ETC

All I want to do is put a function around the outside of this formula that extracts only the number.

So it would read 8 if the result of the inside formula was SPEC-8 or 1.5 if it was BID-1.5.

I'm wondering if there's a custom VBA function to do it that would look like this:

Code:
=ExtractNumber(IFERROR(IF(BJ3>Y3,M3,VLOOKUP(F3,'Bid Template'!L:CU,88,FALSE)),M3))

Any ideas?

Thanks!
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
See if this formula gives you want you want (I have already incorporated the formula you posted into it)...

=TRIM(RIGHT(SUBSTITUTE(IFERROR(IF(BJ3>Y3,M3,VLOOKUP(F3,'Bid Template'!L:CU,88,FALSE)),M3),"-",REPT(" ",99)),99))
 
Upvote 0
Try this:
=MID(IFERROR(IF(BJ3>Y3,M3,VLOOKUP(F3,'Bid Template'!L:CU,88,FALSE)),M3),SEARCH("-",IFERROR(IF(BJ3>Y3,M3,VLOOKUP(F3,'Bid Template'!L:CU,88,FALSE)),M3))+1,99)+0
The +0 at the end convert the value from text to number if you need o do calculations With it afterwards.
Skip +0 if you want the result to be formatted as text.
 
Upvote 0
Both formulas almost worked, except sometimes I have "BID-.48" and they both turned this number into 19389.51. I just want it to turn into .48. For all the whole numbers it worked fine though. Any ideas?
 
Last edited:
Upvote 0
Both formulas almost worked, except sometimes I have "BID-.48" and they both turned this number into 19389.51. I just want it to turn into .48. For all the whole numbers it worked fine though. Any ideas?
You apparently did not see the formula I posted in Message #2 yet as I do not think it could be returning such a value.

By the way, it is always a good idea to post who you are replying to when you have more than one response.
 
Upvote 0
You apparently did not see the formula I posted in Message #2 yet as I do not think it could be returning such a value.

By the way, it is always a good idea to post who you are replying to when you have more than one response.

I did see your message. However, it was my fault, I had a vlookup in pulling off of another tab. My apologies :)
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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