PC Review


Reply
Thread Tools Rate Thread

Adding If Statements to Macro Code

 
 
TKrepitch@aol.com
Guest
Posts: n/a
 
      20th May 2006
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

 
Reply With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      20th May 2006
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



In article <(E-Mail Removed)>,
(E-Mail Removed) wrote:

> 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

 
Reply With Quote
 
TKrepitch@aol.com
Guest
Posts: n/a
 
      22nd May 2006
Very cool. Thank you!

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Mutiple Where Statements to Code Blakey300 Microsoft Access VBA Modules 18 15th May 2009 04:42 PM
Adding Mutiple Where Statements to Code Blakey300 Microsoft Access VBA Modules 0 15th May 2009 12:08 PM
Re: Multiple If Statements or Macro's in Worksheet:View Code Scott Microsoft Excel Misc 0 29th Dec 2006 12:31 AM
Re: Multiple If Statements or Macro's in Worksheet:View Code Scott Microsoft Excel Misc 0 28th Dec 2006 07:27 PM
Adding macro code to Personal Macro Workbook mika Microsoft Excel Misc 2 16th Oct 2003 09:35 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:31 AM.