PDA

View Full Version : Conversion of formula to userform or button



raviprakash
02-27-2017, 12:21 AM
Hi All,
I am Design engineer and very new to excel. Need some help for conversion of formula to userform or button for quick access.
Below are the formulae need to be converted.
For condition 1 :
1. Nominal value : LEFT(B2,FIND("±",B2)-1)
2. Upper Tolerance : SUBSTITUTE(B2,CONCATENATE(C2,"±"),"")
3. Lower Tolerance : SUBSTITUTE(B2,CONCATENATE(C2,"±"),"")

For condition 2 :
1. Nominal value : MID(B3,1,FIND("+",B3)-1)
2. Upper Tolerance : MID(B3,FIND("+",B3),FIND("-",B3)-FIND("+",B3))
3. Lower Tolerance : MID(B3,FIND("-",B3),LEN(B3)-(FIND("-",B3)-1))

For condition 3 :
1. Nominal value : MID(B4,1,FIND(CHAR(10),B4))
2. Upper Tolerance : MID(B4,FIND(CHAR(10),B4),LEN(B4)-FIND(CHAR(10),B4)+1)

If anyone know the solution please help me out.

Thanks in advance.

Regards,
Ravi

SamT
02-27-2017, 05:52 PM
User Defined Type


Public Type Condition
NominalValue as Double
UpperTolerance As Double
LowerTolerance As Double
End Type


Sub Example
Dim Condition1 as Condition
Dim Condition2 as Condition
Dim Condition3 as Condition

With Condition1
.NominalValue = LEFT(B2,FIND("±",B2)-1)
.UpperTolerance = SUBSTITUTE(B2,CONCATENATE(C2,"±"),"")
.LowerTolerance = SUBSTITUTE(B2,CONCATENATE(C2,"±"),"")
End With

'With Condition2
'Same as above

'Ignore Condition3.LowerTolerance

raviprakash
02-27-2017, 09:17 PM
Thank you SamT for your support.

p45cal
02-28-2017, 04:33 AM
cross post:
http://www.ozgrid.com/forum/showthread.php?t=203031

It would be helpful to know what sort of data these formulae work on, and whether (as I suspect) some of these work on each other.