Hi Everyone,
I have a userform with a textbox, the contents of which are determined by a formula applied to other textboxes and if certain conditions are met. The textbox that this calculation applies to is "TextPremium"
The gist of it is that I want to be able to calculate the increase in a cost if some jobs are done at higher than normal rates (i.e. out of hours)
I am struggling to get this to work at all and would be grateful if someone can help with this:
Private Sub PremiumCalc()
Dim Var1, Var2, Var3, Var4, Var5, Var6, Var7, Var8, Var9, Var10 As Double
If Text1.Value <> "" Then
Var3 = Text1.Value
Else: Var3 = 0
If Text2.Value <> "" Then
Var4 = Text2.Value
Else: Var4 = 0
If Text3.Value <> "" Then
Var5 = Text3.Value
Else: Var5 = 0
If Text4.Value <> "" Then
Var6 = Text4.Value
Else: Var6 = 0
If Text7.Value <> "" Then
Var7 = Text7.Value
Else: Var7 = 0
If Text8.Value <> "" Then
Var8 = Text8.Value
Else: Var8 = 0
If TextTotalB.Value <> "" Then
Var9 = TextTotalB.Value
Else: Var9 = 0
Var1 = (Me.TextTotalA + VarB)
Var10 = (Var3 + Var4 + Var5 + Var6 + Var7 + Var8)
Var2 = ((Var1 - Var10) * TextRate1.Value)
Me.TextPremium.Value = (Var2 + (Var3 * TextRate2.Value) + (Var4 * TextRate2.Value) + _
(Var5 * TextRate3.Value) + (Var6 * TextRate4.Value) + (Var7 * TextRate5.Value) + (Var8 * TextRate6.Value))
End If
End If
End If
End If
End If
End If
End If
End Sub
Many thanks in advance
I have a userform with a textbox, the contents of which are determined by a formula applied to other textboxes and if certain conditions are met. The textbox that this calculation applies to is "TextPremium"
The gist of it is that I want to be able to calculate the increase in a cost if some jobs are done at higher than normal rates (i.e. out of hours)
I am struggling to get this to work at all and would be grateful if someone can help with this:
Private Sub PremiumCalc()
Dim Var1, Var2, Var3, Var4, Var5, Var6, Var7, Var8, Var9, Var10 As Double
If Text1.Value <> "" Then
Var3 = Text1.Value
Else: Var3 = 0
If Text2.Value <> "" Then
Var4 = Text2.Value
Else: Var4 = 0
If Text3.Value <> "" Then
Var5 = Text3.Value
Else: Var5 = 0
If Text4.Value <> "" Then
Var6 = Text4.Value
Else: Var6 = 0
If Text7.Value <> "" Then
Var7 = Text7.Value
Else: Var7 = 0
If Text8.Value <> "" Then
Var8 = Text8.Value
Else: Var8 = 0
If TextTotalB.Value <> "" Then
Var9 = TextTotalB.Value
Else: Var9 = 0
Var1 = (Me.TextTotalA + VarB)
Var10 = (Var3 + Var4 + Var5 + Var6 + Var7 + Var8)
Var2 = ((Var1 - Var10) * TextRate1.Value)
Me.TextPremium.Value = (Var2 + (Var3 * TextRate2.Value) + (Var4 * TextRate2.Value) + _
(Var5 * TextRate3.Value) + (Var6 * TextRate4.Value) + (Var7 * TextRate5.Value) + (Var8 * TextRate6.Value))
End If
End If
End If
End If
End If
End If
End If
End Sub
Many thanks in advance