Removing text after numbers

Kingkoopa

Board Regular
Joined
Aug 7, 2014
Messages
94
Hi Guys,

Using windows 7 and excel 2007.

Reposting this I think there was a forum roll back?? Couldn't log in the whole afternoon kept giving a 404 error and found my thread had disappeared.


I have the following set of data :

Apple 330grams
Apple 29 kilo
Pear 21 baskets
Pear & Apples 12 total

<tbody>
</tbody>

I would like to remove all the text after the numbers. Thus I would get the following results :

Apple 330
Appel 29
Pear 21
Pear & Apples 12

Any idea guys?

I saw someone posting the solution but its gone now when I try to search back the thread :(.


Thank you
 
Last edited:

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG07Dec14
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
[COLOR="Navy"]For[/COLOR] n = 1 To Len(Dn.Value)
    [COLOR="Navy"]If[/COLOR] Dn.Characters(n, 2).Text Like "[0-9][ ]" [COLOR="Navy"]Then[/COLOR]
        Dn.Value = Mid(Dn.Value, 1, n + 1)
    [COLOR="Navy"]ElseIf[/COLOR] Dn.Characters(n, 2).Text Like "[0-9][a-z]" [COLOR="Navy"]Then[/COLOR]
        Dn.Value = Mid(Dn.Value, 1, n)
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,867
Messages
5,834,087
Members
430,260
Latest member
MANICX100

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
Top