In excel, I'm trying to find letters and the 1st number in a string from the left. What is the formula?

Here is my example ABRAME124001 the answer should be ABRAME1.  

Thank you!
RachelAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
if the prefix char comes with fixed length, then try formula:

=left(A2, 7)

Open in new window


where A2 = ABRAME124001

else we should write a custom function to achieve this, but you got to tell us more details about your value.
0
RachelAuthor Commented:
Thank you.  The number of char (letters) before the number is not always the same amount.
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
try write a custom function like this:

Function getString(v As String) As String
    v = UCase(v)
    For i = 1 To Len(v)
        If Asc(Mid(v, i, 1)) >= 65 And Asc(Mid(v, i, 1)) <= 90 Then
            getString = getString & Mid(v, i, 1)
        Else
            getString = getString & Mid(v, i, 1)
            Exit Function
        End If
    Next
End Function

Open in new window


then use it like:

=getString(A2)

Open in new window


where A2 = ABRAME124001
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Or something like this...

Function getString(ByVal str As String) As String
Dim i As Integer
Dim resStr As String
For i = 1 To Len(str)
    If IsNumeric(Mid(str, i, 1)) Then
        resStr = resStr & Mid(str, i, 1)
        getString = resStr
        Exit Function
    Else
        resStr = resStr & Mid(str, i, 1)
    End If
Next i
End Function

Open in new window

Then if your string is in A2, try this...
In B2
=getString(A2)

Open in new window

0
Ejgil HedegaardCommented:
You can use this formula
=LEFT(A2,SEARCH(RIGHT(A2,LEN(A2)-MIN(FIND(0,SUBSTITUTE(A2,{1,2,3,4,5,6,7,8,9},0)&0))+1),A2))

Open in new window

0
aikimarkCommented:
@Rachel

Will there ever be letter(s) after any digit(s)?

Will there ever be any characters other than letters and numbers?
0
RachelAuthor Commented:
@ Ejgil - thank you but the result with your formula gave me a result of 1.  I need to get the letters along with the first number in the string.

@ aikimark - there will not be letters after the 1st number is found.  There will not be any other characters - only letters and numbers.

To all others who provided function code results, I have no idea where to put that function code - I only how to add copy and paste the formula - sorry - code is over my head.

Thanks All!
0
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
I have no idea where to put that function code - I only how to add copy and paste the formula
you can create a Module and paste the codes there.

Create custom functions in Excel
https://support.office.com/en-us/article/create-custom-functions-in-excel-2f06c10b-3622-40d6-a1b2-b6748ae8231f
0
Ejgil HedegaardCommented:
It does that, see sheet.
Rachel-Text-and-first-number.xlsx
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
RachelAuthor Commented:
Thank you Ejgil - that worked!
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.