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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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
 
Upvote 0

Forum statistics

Threads
1,215,731
Messages
6,126,537
Members
449,316
Latest member
sravya

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