Convert text to numbers in cell where text is extracted from another cel

ajarle

New Member
Joined
Jun 6, 2012
Messages
13
I am using this formula in B2 to extract the number "100" from A2 containing this text string: "viewport: 100x30".

=
IFERROR(MID(A2,FIND(" ",A2)+1,FIND("x",A2)-FIND(" ",A2)-1))

All good so far.

However, I want the formula result to be formatted as a number. I am unable to change the cell format in the formula cell.

I am using Google sheets.
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Using VALUE you convert text to number. So just add VALUE at the beginning of your formula.
 
Upvote 0
try this

=IFERROR(VALUE(MID(A2,FIND(" ",A2)+1,FIND("x",A2)-FIND(" ",A2)-1)),"")

you need to add this "" when it's an error
 
Upvote 0
ajarle,

How about something like this?


Excel 2007
ABC
2viewport: 100x30100100
Sheet1
Cell Formulas
RangeFormula
C2=IFERROR(VALUE(MID(A2,FIND(" ",A2)+1,FIND("x",A2)-FIND(" ",A2)-1)),"")
B2{=MAX(IF(ISNUMBER(--MID(SUBSTITUTE(A2," ","x"),MOD(ROW(INDIRECT("1:"&LEN(A2)^2)),LEN(A2))+1,CEILING(ROW(INDIRECT("1:"&LEN(A2)^2))/LEN(A2),1))),--MID(A2,MOD(ROW(INDIRECT("1:"&LEN(A2)^2)),LEN(A2))+1,CEILING(ROW(INDIRECT("1:"&LEN(A2)^2))/LEN(A2),1))))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Last edited:
Upvote 0
ajarle,

Thanks for the feedback.

You are very welcome. Glad we could help.

And, come back anytime.
 
Upvote 0
Can I ask why this?
Doesn't this do the same?
=MID(A1,FIND(" ",A1)+1,FIND("x",A1)-FIND(" ",A1)-1)+0

ajarle,

How about something like this?

Array Formulas
CellFormula
B2{=MAX(IF(ISNUMBER(--MID(SUBSTITUTE(A2," ","x"),MOD(ROW(INDIRECT("1:"&LEN(A2)^2)),LEN(A2))+1,CEILING(ROW(INDIRECT("1:"&LEN(A2)^2))/LEN(A2),1))),--MID(A2,MOD(ROW(INDIRECT("1:"&LEN(A2)^2)),LEN(A2))+1,CEILING(ROW(INDIRECT("1:"&LEN(A2)^2))/LEN(A2),1))))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,603
Messages
6,125,788
Members
449,260
Latest member
Mrw1

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