![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
I'm trying to separate the numeric data from cells in column A of a worksheet. Unfortunately the cells contain a non consistent mix of alphnumeric data. I've checked out the thread -
http://www.mrexcel.com/board/viewtop...ic=335&forum=2 - but the solutions there were not completely applicable to my problem. Can anyone help? The data in column A contains variations of the following: 1846072 MT-AMOT TFR 1235679 MAN TEL FROM CM 11030 3 RETRY NO CAL BM-BRIM COM 1281838 CM 13538 0 8621 EXPEN Many thanks |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Quote:
Code:
Function ExtractNumbers(Address As Range)
Dim Position1 As Long
Dim Position2 As Long
Dim Counter As Long
Application.Volatile
For Counter = 1 To Len(Address)
If Position1 = 0 Then
If IsNumeric(Mid(Address.Value, Counter, 1)) Then Position1 = Counter
Else
If IsNumeric(Mid(Address.Value, Counter, 1)) Then Position2 = Counter
End If
Next Counter
ExtractNumbers = Mid(Address.Value, Position1, Position2 - Position1 + 1)
End Function
=ExtractNumbers(A1) Note - this function assumes your numbers are always grouped together (i.e., not something like "ABC 1234 ABC 1234"). Hope this helps you out. Regards, _________________ Barrie Davidson My Excel Web Page [ This Message was edited by: Barrie Davidson on 2002-05-14 07:32 ] |
|
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
Many, many thanks, Barrie - that solution was absolutely brilliant. What a great site this is!
rollo |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|