Formula to find 2nd number in a cell

j8mie

New Member
Joined
Aug 23, 2011
Messages
4
Hope someone might be able to help me with a formula that's been doing my head in for a few of days now.

Basically I would like to split the contents of a cell into separate parts without using Text to Columns.

The data is always in the following format, word, space, number (0-9), hyphen, number (0-9), space, word

eg
Castle 5-7 Fort
Temple 1-0 House
Cathedral 0-4 Church

I've had no problems getting the first word, first number and last word into new cells. But it's that second number after the hyphen which seems to be impossible to get into a cell on it's own.

Can anyone help?
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
j8mie,

If the second number is always only one digit, you can use the following:
=MID(A1,FIND("-",A1)+1,1)

~tigeravatar
 
Upvote 0
=VALUE(MID(A1,IFERROR(FIND("-",A1,1),0)+1,(SEARCH(" ",A1,IFERROR(FIND("-",A1,1),0))-IFERROR(FIND("-",A1,1),0))))

finds the value regardless of length (assuming a space always follows the second number)
 
Upvote 0
Thank you so much everyone. Those formulas worked like a charm.

I can't believe I was so close. I had =mid(a1,find("-",a1),1). Leaving out the +1 meant I kept getting "-".

Thanks once again :)
 
Upvote 0
Welcome to the MrExcel board!

If you actually wanted the number (as opposed to a text value), you could modify it to ..
=-MID(A1,FIND("-",A1),2)
 
Upvote 0
Just run into another problem. Turns out some of the words might have a space in them

eg
Castle 5-7 Fort William
Temple 1-0 House
Cathedral Tower 0-4 Church

The formula I was using for the first word was.
=IF(ISERR(FIND(" ",B3)),B3,LEFT(B3,FIND(" ",B3)))
This would only pick up Castle, Temple and Cathedral from the list above.

And this is the formula I used to pick out the second word
=RIGHT(B3,LEN(B3)-FIND("*",SUBSTITUTE(B3," ","*",LEN(B3)-LEN(SUBSTITUTE(B3," ","")))))
This would only pick up William, House and Church from the list above.

Any thoughts how to pick up all the text before the first number, and all the text after the second number. There will always be a space between the numbers and text if that makes it any easier.
 
Upvote 0
Assuming still the numbers are single-digit and no spaces in the 'digit-digit' section, try these.

Excel Workbook
ABC
1
2Castle 5-7 FortCastleFort
3Temple 1-0 HouseTempleHouse
4Cathedral 0-4 ChurchCathedralChurch
5Castle 5-7 Fort WilliamCastleFort William
6Temple 1-0 HouseTempleHouse
7Cathedral Tower 0-4 ChurchCathedral TowerChurch
Extract Number
 
Upvote 0
Hi,

Try this: =LEFT(A1,FIND("-",A1)-2) for word from left side and =RIGHT(A1,LEN(A1)-(FIND("-",A1)+2)) for word in right side
 
Last edited:
Upvote 0
Thank you once again. Both of those formulas do the job perfectly.

This site has proved very useful in such a short space of time. Thank you for taking the time to help me out.
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,903
Members
452,948
Latest member
Dupuhini

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