user3667535
user3667535

Reputation: 25

Separate number with symbol in Excel

I am looking for a function in Microsoft Excel that can separate number with symbol. For the example :

I want to separate number in this code:

12345_ABCD

I am looking for a function that can enables me to get the number (in this case 12345) without another character (in this case _ABCD).

And the problem is the the total character of number can be vary. For the example, it can be 12345_ABCD or 234_ABC or 34567_AB.

Please kindly help my problem. Thanks for your concern

Upvotes: 0

Views: 1230

Answers (2)

Karthick Gunasekaran
Karthick Gunasekaran

Reputation: 2713

Here is the function to get the number alone (in your case)

Public Function segregatenumber(a As String)
    segregatenumber = Left(a, InStr(a, "_") - 1)
End Function

then you may use it as function in Excel cells

enter image description here

Upvotes: 0

Maco
Maco

Reputation: 429

If your cells always have numbers in front and then an underscore you could use this:

=Left(A1;Find("_";A1)-1)

Upvotes: 1

Related Questions