LoneReaper
01-15-2017, 03:21 PM
Hi everyone.
Got another one for the VBA gurus if they don't mind. So I think I'm making progress on understanding Dim and producing the results I want, however there is still some ... complications I am having with my current code.
What I would like to achieve is the following:
Client A wishes to purchase an item and the item comes to X dollar value.
This client also receives a commission off this item (Y). Depending on how much this client has spend their commission value may increase during the order.
For example:
Say a client orders an item worth $4,000. This client has also already ordered $18,000 worth of goods and at $20,000 their commission value will increase. Therefore this particular order would be charged 35% commission on $2,000 and 40% commission on the remaining $2,000.
The code I am using is as follows:
If CheckBox10.Value = True Then
Dim mcmessage, mctitle, mcdefault, fmcresult, fmc, fmcComm1, fmcComm2
mcmessage = "Enter Brokers Current Total $ of Sales"
mctitle = "Multiple Commissions"
mcdefault = "0"
fmc = InputBox(mcmessage, mctitle, mcdefault)
If fmc + TextBox7 < 20000 Then
TextBox9 = TextBox7.Value - (((Val(35 / 100)) * TextBox7.Value))
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
ElseIf fmc + TextBox7.Value < 40000 Then
fmcComm1 = fmc + TextBox7 - Val(20000)
fmcComm2 = TextBox7 - fmcComm1
TextBox9 = (fmcComm2 - ((Val(35 / 100)) * fmcComm2)) + (fmcComm1 - ((Val(40 / 100)) * fmcComm1.Value))
Set fmcresult = ActiveDocument.Tables(1).Cell(18, 2).Range
fmcresult.Text = "(35 - 40%)"
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
ElseIf fmc + TextBox7.Value < 60000 Then
fmcComm1.Value = fmc + TextBox7.Value - Val(40000)
fmcComm2.Value = TextBox7.Value - fmcComm1.Value
TextBox9.Value = (fmcComm2.Value - ((Val(40 / 100)) * fmcComm2.Value)) + (fmcComm1.Value - ((Val(45 / 100)) * fmcComm1.Value))
Set fmc = ActiveDocument.Tables(1).Cell(18, 2).Range
fmc.Text = "(40 - 45%)"
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
ElseIf fmc + TextBox7.Value > 60000 Then
fmcComm1 = fmc + TextBox7.Value - Val(60000)
fmcComm2 = TextBox7.Value - fmcComm1
TextBox9.Value = (fmcComm2 - ((Val(45 / 100)) * fmcComm2)) + (fmcComm1 - ((Val(50 / 100)) * fmcComm1))
Set fmc = ActiveDocument.Tables(1).Cell(18, 2).Range
fmc.Text = "(45 - 50%)"
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
End If
End If
If anyone would like me to explain any variables any further please let me know. I know I'll be wracking my brain over this and I think it would be easier if I saw where I am wrong so I can learn from the error.
Thank you in advance.
Got another one for the VBA gurus if they don't mind. So I think I'm making progress on understanding Dim and producing the results I want, however there is still some ... complications I am having with my current code.
What I would like to achieve is the following:
Client A wishes to purchase an item and the item comes to X dollar value.
This client also receives a commission off this item (Y). Depending on how much this client has spend their commission value may increase during the order.
For example:
Say a client orders an item worth $4,000. This client has also already ordered $18,000 worth of goods and at $20,000 their commission value will increase. Therefore this particular order would be charged 35% commission on $2,000 and 40% commission on the remaining $2,000.
The code I am using is as follows:
If CheckBox10.Value = True Then
Dim mcmessage, mctitle, mcdefault, fmcresult, fmc, fmcComm1, fmcComm2
mcmessage = "Enter Brokers Current Total $ of Sales"
mctitle = "Multiple Commissions"
mcdefault = "0"
fmc = InputBox(mcmessage, mctitle, mcdefault)
If fmc + TextBox7 < 20000 Then
TextBox9 = TextBox7.Value - (((Val(35 / 100)) * TextBox7.Value))
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
ElseIf fmc + TextBox7.Value < 40000 Then
fmcComm1 = fmc + TextBox7 - Val(20000)
fmcComm2 = TextBox7 - fmcComm1
TextBox9 = (fmcComm2 - ((Val(35 / 100)) * fmcComm2)) + (fmcComm1 - ((Val(40 / 100)) * fmcComm1.Value))
Set fmcresult = ActiveDocument.Tables(1).Cell(18, 2).Range
fmcresult.Text = "(35 - 40%)"
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
ElseIf fmc + TextBox7.Value < 60000 Then
fmcComm1.Value = fmc + TextBox7.Value - Val(40000)
fmcComm2.Value = TextBox7.Value - fmcComm1.Value
TextBox9.Value = (fmcComm2.Value - ((Val(40 / 100)) * fmcComm2.Value)) + (fmcComm1.Value - ((Val(45 / 100)) * fmcComm1.Value))
Set fmc = ActiveDocument.Tables(1).Cell(18, 2).Range
fmc.Text = "(40 - 45%)"
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
ElseIf fmc + TextBox7.Value > 60000 Then
fmcComm1 = fmc + TextBox7.Value - Val(60000)
fmcComm2 = TextBox7.Value - fmcComm1
TextBox9.Value = (fmcComm2 - ((Val(45 / 100)) * fmcComm2)) + (fmcComm1 - ((Val(50 / 100)) * fmcComm1))
Set fmc = ActiveDocument.Tables(1).Cell(18, 2).Range
fmc.Text = "(45 - 50%)"
TextBox10.Value = Format(Val((TextBox9.Value) * Val(0.1)), "###0.00")
TextBox11.Value = Format(Val(TextBox9.Value) + Val(TextBox10.Value), "###0.00")
End If
End If
If anyone would like me to explain any variables any further please let me know. I know I'll be wracking my brain over this and I think it would be easier if I saw where I am wrong so I can learn from the error.
Thank you in advance.