Quick Question - Extract Number from String

D

Damil4real

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!
 
W

wdkempf

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!

This should do it for you: =LEFT(A1,FIND("-",A1)-1) (this
assuming your data is in A1)
 
J

Jim

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!

Try:
x= val("01458-MODE...")
x should be 1458

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top