Using LEFT (or other functions) where the "=" is part of the formula?

boznian

Board Regular
Joined
Mar 25, 2003
Messages
167
I need to sort, and maybe filter, and find values from program code. Unfortunately the character(s) that I need are the 2 to the left of an = (equals) sign. I haven't found any way to use the = sign IN the formula - is this possible? It gave me a tip to place a single quote prior to the = sign but the formula still crashed. Excel 2000 FWIW. Example data, column A, what I need for column B:
y2=0.0 ...so I need "y2"
forcedmin1=auto ...so I need n1
max0=200.0 ...so I need x0
etc.

Every line is a different total length and the = sign is always in a different place so I can't use any 'fixed' parameters.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
You can use SEARCH to find location of = . Then use MID to extract data.

Say forcedmin1=auto is in cell "M2". The formula would be =MID(M2,SEARCH("=",M2)-2,2)
 
Upvote 0
I thought I was done, but new data shows I didn't plan ahead well enough and I didn't ask the right question. I need UP TO the 2 characters to the left of the = sign, but only the NUMBERS. So the raw code may look like this:
id10= ... I need 10
pale220= ... I need 20
nit1= ... I need 1
x0= ... I need 0
How do I return just the 1 or 2 digit numeric value prior to the = sign?
I can do this to get the starting position of the number, but haven't been able to go further:
=MIN(FIND({0,1,2,3,4,5,6,7,8,9},C60&"0123456789"))
 
Upvote 0
It is easier to do with VBA. Are you familiar with VBA?
 
Upvote 0
How about
Excel Formula:
=IFERROR(MID(A2,FIND("=",A2)-2,2)+0,MID(A2,FIND("=",A2)-1,1))
 
Upvote 0
Solution
That seems to work well! Let me do a little further testing on the actual code from today...
Yes, that should work perfectly. I was thinking if you have so many rows, long formula would invisibly bloat the file size ?

I though creating a UDF would be better.

I was about to proposed this

VBA Code:
Function GetNum(cell As Range) As Long

Dim n&

Select Case True
    Case cell Like "*##=*"
        GetNum = Mid(cell, Application.Find("=", cell) - 2, 2)
    Case cell Like "*#=*"
        GetNum = Mid(cell, Application.Find("=", cell) - 1, 1)
End Select

End Function
 
Upvote 0

Forum statistics

Threads
1,214,978
Messages
6,122,545
Members
449,089
Latest member
davidcom

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