Find whole number in string

sharky12345

Well-known Member
Joined
Aug 5, 2010
Messages
3,404
Office Version
  1. 2016
Platform
  1. Windows
Really struggling with this one, must be a simple solution....

I need to search a column for an exact match to a whole number - each row contains a mixture of letters and numbers. Once found I just need to store the row number.

Note, with this though I need to be sure it does find precise matches, so if I searched for "2213" I would not want it to return a find for "22131".

The search range is sheet4 column A, (from A2 to the last used row), the value to search will change and I haven't decided how the user will carry out the search yet so for this purpose lets assume the search number will be "2213".

Can anyone help me please?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Any thoughts on why wouldnt MATCH formula wont work?

For example,

Code:
=MATCH(2213,A1:A10,0)
 
Upvote 0
Hi, thanks - didn't think of that, will give it a go, though the search value and search range are on 2 different sheets - will try it and report back.
 
Upvote 0
That suggestion doesn't work I'm afraid - it gives me 'N/A'
 
Upvote 0
Can you supply a few examples of your data?
 
Upvote 0
Sure....

The search item will always be a number and can be 3, 4 or 5 digits. The search range will contain data that consists of both numbers and characters like this:

'TG 28726 HGHTYRDHJTRFV'

Not sure if it would make a difference but the string to search may also have a forward slash in it like this:

'T/GS 356 HFDSFGY'

Does this help?
 
Upvote 0
Is there always a space before and after the number? Is the number always the second "section" of the string?

If so, try this, if the number is in A1 (and fill down):

Code:
=TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),LEN(A1)+1,LEN(A1)))
 
Upvote 0
kweaver - thanks, yes, you're assumption is correct and your formula works for me...thanks!
 
Upvote 0
kweaver - thanks, yes, you're assumption is correct and your formula works for me...thanks!
:confused: Your original post was about "searching" for a particular string (example was 2213) in a range of cells in column A. Has your requirement now changed to not looking for any particular number nor to look in a range of cells but just extract whatever the number is from each cell?

If the suggested formula in post 7 does actually do what you want, then this should also, given the assumptions and your information in post 6.

=MID(SUBSTITUTE(A1," ","  "),FIND(" ",A1),7)+0
 
Upvote 0
Just another way

=MID(SUBSTITUTE(A1," ",REPT(" ",99)),99,99)+0
 
Upvote 0

Forum statistics

Threads
1,214,846
Messages
6,121,905
Members
449,054
Latest member
luca142

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