Deleting text after a number with vba

I am using Excel 2003

I am looking for vba code that will look at a cell and delete all spaces and text after the first occuring string of numbers (this could be any random numbers 100.00 or 10,000 or 0.00 or 0  with or without a decimal point).

Therefore if the cell has "Marketing Area 234.0 plus any text which may include a randum number like 99" what I need is "Marketing Area 234.0"

Therefore if the cell has "Book Plot 9,234 plus any extra text which may include a randum number  102 for example" what I need is "Book Plot 9,234"

Many thanks
LVL 1
PeterWhittsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jorge PaulinoIT Pro/DeveloperCommented:
Try this way =GetPartialText(A1)
Public Function GetPartialText(rng As Range) As String
Dim str() As String, s As Variant
Dim result As String

str = Split(rng.Value)

For Each s In str
    result = result & " " & s
    If IsNumeric(Replace(s, ",", ".")) Then Exit For
Next

GetPartialText = Trim(result)

End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jorge PaulinoIT Pro/DeveloperCommented:
Place this function in a module
0
PeterWhittsAuthor Commented:
Thanks for that but it doesn't work for "Book Plot 9,234.00 plus any extra text which may include a randum number  102 for example".

You get the whole string
0
Saqib Husain, SyedEngineerCommented:
in jpaulino's solution change

    If IsNumeric(Replace(s, ",", ".")) Then Exit For
to
    If IsNumeric(Replace(s, ",", "")) Then Exit For
0
PeterWhittsAuthor Commented:
Many thanks for the joint answer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.