Adding If Statements to Macro Code

T

TKrepitch

I have the code below in a spreadsheet, but I need to adjust it. I
want it to continue to do the calculation, but need it to say "Exceeds
Maximum Allowable" if the result (discount) is above 70%.

I am venturing into VBA for the first time, so I really appreciate
anyone's help. :)


Sub Calc_Discount()
'
' Calc_Discount Macro
' Calculate Maximum Discount
'

'
Range("d27").GoalSeek Goal:=0.3, ChangingCell:=Range("discount")
End Sub
 
J

JE McGimpsey

One way:

Public Sub Calc_Discount()
'
' Calc_Discount Macro
' Calculate Maximum Discount
'

'
Range("d27").GoalSeek Goal:=0.3, ChangingCell:=Range("discount")
If Range("discount").Value > 0.7 Then _
MsgBox "Exceeds Maximum Allowable"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top