View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
DonkeyOte[_3_] DonkeyOte[_3_] is offline
external usenet poster
 
Posts: 2
Default Please assist. Extract Number from String

You don't specify

a) ranges
b) overwrite original or adjacent columns

Assuming say a range of A1:A6 and overwrite

With Range("A1:A6")
.Value = Evaluate("IF(ROW(" & .Address & "),LEFT(" & .Address &
",FIND(""-""," & .Address & ")-1))")
End With

that would however return the numbers as numbers - if you wish to return as
strings use ""'""&LEFT(...)
"Damil4real" wrote:

How can I use a macro to extract only the first batch of numbers from
the following type of info?

Examples:

01458-MODE
1548-JUNE
1245-NOD
01054-MORNING
00154-JUNE
55145-55145

Result should be:

01458
1548
1245
01054
00154
55145
--------------------

I only need the first batch of numbers before the "-" sign. There will
always be this sign "-" separating the two batch of data.

Thanks!
.