Extract only the numbers

gpapagre

New Member
Joined
Mar 6, 2009
Messages
18
Dear all,

thanks for your hospitality. this is the second time i post a question to this board, hopefully i will get the same help as in the first time when NMeeker solved my problem with missing invoices. i thank him very much.

my question is simple.

In column A I have a list of numbers which unfortunalely sometimes when I extract them from accounting softwares are in the form of letters, commas etc plus the numbers. examples: INVOICE_5526, INV-2343, INV/3369 and in other formats. What I want to have in column B is just the numbers.

Is there a formula I can apply in any case to isolate only the numbers?

Thank you all
George
 
In your examples the numbers are always the last part of the string.

If that's always the case, for numbers with less that 10 digits:

=LOOKUP(10^10,--RIGHT(A7,{1,2,3,4,5,6,7,8,9}))
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Also:

=REPLACE(A2,1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))-1,"")+0

if only the last part is numeric as in INVOICE_5526, INV-2343, and INV/3369.
 
Upvote 0
Ah ok... I thought that example was all 1 string in one cell! :rolleyes:
 
Upvote 0
Hello, thanks for your macro. have tried it but doesnt work. can you help?

Another option for a UDF:

Code:
Function OnlyDigits(s As String) As String
 
With CreateObject("vbscript.regexp")
    .Pattern = "\D"
    .Global = True
    OnlyDigits = .Replace(s, "")
End With
End Function
 
Upvote 0
In your examples the numbers are always the last part of the string.

If that's always the case, for numbers with less that 10 digits:

=LOOKUP(10^10,--RIGHT(A7,{1,2,3,4,5,6,7,8,9}))


thanks,
can you tell me please...when i copy / paste this formula to my excel 2003 doesnt work. do i do anything wrong?
 
Upvote 0
I just tried it in xl2000 with no problem. Did you replace A7 with the address of the input cell?
 
Upvote 0
I just tried it in xl2000 with no problem. Did you replace A7 with the address of the input cell?

hI SIR, the problem is with me,not your formula. have tried again with other formulas and dont function.

i highlight and then copy / paste the formula to my formula bar or in B1. say i have A1:A100 (100 numbers with letters).
 
Upvote 0
With
A1: (an invoice reference)

Try this:
Code:
B1: =--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),99)

Examples:
INV-1000......Formula returns: 1000
INV/4321......Formula returns: 4321
INV.98764.....Formula returns: 98764

Does that help?
 
Upvote 0
With
A1: (an invoice reference)

Try this:
Code:
B1: =--MID(A1,MIN(SEARCH({0,1,2,3,4,5,6,7,8,9},A1&"0123456789")),99)

Examples:
INV-1000......Formula returns: 1000
INV/4321......Formula returns: 4321
INV.98764.....Formula returns: 98764

Does that help?

hi, thank you. when i copy/paste the above formula in B1 doesnt do anything. Wondering why is that happening not only with this formula but also with almost all others. can you advice?
 
Upvote 0
hi, thank you. when i copy/paste the above formula in B1 doesnt do anything. Wondering why is that happening not only with this formula but also with almost all others. can you advice?

There must be happening something. Are you seeing the formula instead of a result?
 
Upvote 0

Forum statistics

Threads
1,216,096
Messages
6,128,807
Members
449,468
Latest member
AGreen17

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