How to Extract Number in Cell with Letters

Justinian

Well-known Member
Joined
Aug 9, 2009
Messages
1,557
Office Version
  1. 365
Platform
  1. Windows
I am using VLOOKUP (trying to at least) to find out how many rooms a hotel suite has. So in A1, for example, is suite 3302F. On another tab with all 1,000 suites numbers, I see 3302F in A23 and in B23, it says "Twr 1B." This is a one-bedroom suite because of the 1 but how do I extract just the number?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Assuming that you could never go over 9B and it always is in the last 2 characters:
=LEFT(RIGHT(B23,2))+0
 
Last edited:
Upvote 0
I've used this and it's worked for me. You'll need to add the code for this function.

Code:
Function GetNumbers(S As String) As String
Dim i As Long
For i = 1 To Len(S)
    If Mid(S, i, 1) Like "[1-9]" Then GetNumbers = GetNumbers & Mid(S, i, 1)
Next i
End Function

Your formula in the cell could then reference that function.

=GetNumbers(A2)
 
Upvote 0
Assuming that you could never go over 9B and it always is in the last 2 characters:
=LEFT(RIGHT(B23,2))+0

Sorry, I should have stated not all numbers are in same place. For example, I could also have 2 GU or 3Sig.
 
Upvote 0
I've used this and it's worked for me. You'll need to add the code for this function.

Code:
Function GetNumbers(S As String) As String
Dim i As Long
For i = 1 To Len(S)
    If Mid(S, i, 1) Like "[1-9]" Then GetNumbers = GetNumbers & Mid(S, i, 1)
Next i
End Function

Your formula in the cell could then reference that function.

That does not work for me.
 
Upvote 0
Sheet1 is the input and Sheet2 is where all the data (suite numbers and room counts) are stored.
 
Upvote 0
Let's say :

Sheet1 A1 = 3302F
Sheet1 B1 =
Twr 3sig

Sheet2 A23 = 3302F
Sheet2 B23 =
(LOOKUP(9^9,0+MID(VLOOKUP(A23,Sheet1!A1:B1,2),MIN(FIND({0,1,2,3,4,5,6,7,8,9},VLOOKUP(A23,Sheet1!A1:B1,2)&1/19)),ROW($1:$16))))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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