Hi Guys,
I have created a Userform that calculates mark-ups and gross margin based on a cost price and sell price.
My problem is that when I enter a sell price into the textbox that is less than the cost price, it shows me a positive mark-up but a negative gross margin.
In this scenario I need it to show me a negative mark-up because the desired sell price is less than the cost price.
All numbers are formatted in currency.
Can anyone help me, I think the problem is in If statement "If Me.RequiredSellPrice.Value >= Me.CurrentCost.Value Then"
Because let's say Me.RequiredSellPrice.Value = $95 and Me.CurrentCost.Value = $100 , my code will treat it as having agreed with the If statement and $95 is not greater than $100
Here is my code below, can anyone see the problem ?
Thanks.
I have created a Userform that calculates mark-ups and gross margin based on a cost price and sell price.
My problem is that when I enter a sell price into the textbox that is less than the cost price, it shows me a positive mark-up but a negative gross margin.
In this scenario I need it to show me a negative mark-up because the desired sell price is less than the cost price.
All numbers are formatted in currency.
Can anyone help me, I think the problem is in If statement "If Me.RequiredSellPrice.Value >= Me.CurrentCost.Value Then"
Because let's say Me.RequiredSellPrice.Value = $95 and Me.CurrentCost.Value = $100 , my code will treat it as having agreed with the If statement and $95 is not greater than $100
Here is my code below, can anyone see the problem ?
Code:
Private Sub RequiredSellPrice_AfterUpdate()
If IsNumeric(Me.SSRRef) Then
If Me.CurrentCostPrice.Text = "$0 in SSR Sheet" Then
Exit Sub
Else
If IsNumeric(Me.RequiredSellPrice.Value) Then
Me.RequiredSellPrice = FormatCurrency(Me.RequiredSellPrice, 2)
If Me.RequiredSellPrice.Value >=Me.CurrentCostPrice.Value Then
Me.Materials1 = FormatPercent(Abs(((Abs(Me.RequiredSellPrice.Value- Range("AJ" & Me.SSRRef + 9) _
- Range("AM" & Me.SSRRef + 9)) / Me.CurrentCostPrice.Value )) - 1), 5)
Me.Materials1.Object.Locked = True
Me.Materials1.BackColor = RGB(192, 192, 192)
Me.GMMat1.Value = (Me.RequiredSellPrice.Value - Me.CurrentCostPrice.Value ) / Me.CurrentCostPrice.Value
Me.GMMat1.Value = FormatPercent(Me.GMMat1.Value / (1 + Me.GMMat1.Value), 4)
Else
Me.Materials1 = FormatPercent(((Me.RequiredSellPrice.Value - Range("AJ" & Me.SSRRef + 9) _
- Range("AM" & Me.SSRRef + 9)) / Me.CurrentCostPrice.Value) + 1, 5)
Me.Materials1.Object.Locked = True
Me.Materials1.BackColor = RGB(192, 192, 192)
Me.GMMat1.Value = (Me.RequiredSellPrice.Value - Me.CurrentCostPrice.Value) / Me.CurrentCostPrice.Value
Me.GMMat1.Value = FormatPercent(Me.GMMat1.Value / (1 + Me.GMMat1.Value), 4)
End If
Else
Me.Materials1 = ""
Me.Materials1.Object.Locked = False
Me.Materials1.BackColor = RGB(255, 255, 255)
Me.GMMat1.Value = ""
End If
End If
End If
End Sub
Thanks.