Reputation: 25
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
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
Upvotes: 0
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