PC Review


Reply
Thread Tools Rate Thread

Beforeprint with multiple If then else statements

 
 
batroni@gmail.com
Guest
Posts: n/a
 
      10th Oct 2007
By combing through discussion groups and experimenting for days, I've
come up with the following. It works as a macro or a "click" event. I
would like to use it as a BeforePrint procedure, but it either stops
after the message box, runs through the second if twice, doesn't print
at all, prints twice, etc.
Sub test()

If Range("y43").Value + Range("y17").Value <> "80" Then
If MsgBox("The total of 'REGULAR' and 'LOST TIME' hours must equal
80. Please correct your timesheet.", _
vbOKOnly, "") = vbOK Then End
End If

If MsgBox("You have not entered miscellaneous hours such as Vacation,
Jury Duty, etc. Is this correct?", _
vbYesNo, "") = vbNo Then
MsgBox ("Please correct your timesheet.")


ElseIf Range("y25").Value = "" Then
ActiveSheet.PageSetup.PrintArea = "$A1:$y66"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Else: ActiveSheet.PageSetup.PrintArea = "$A1:$y129"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End If

End Sub

If possible I would also like to add and If then else statement based
on the following formula:

=IF(OR((AND(HolidayHours=1,SUM(sheet1:sheet4!Y21:Y22)=29)),
(AND(HolidayHours=2,SUM(Op1:test!Y21:Y22)=32)),
(AND(HolidayHours=0,SUM(Op1:test!Y21:Y22)=26))),"","please check
hours")


I don't even know if I'm asking a lot since I don't really know what
I'm doing; but thanks for whatever help you can give!

Venus

 
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
Multiple Update Set Statements or Multiple DML Statements in one thedudeminds@msn.com Microsoft Access Queries 4 11th Sep 2007 06:34 PM
Multiple IF statements looking up multiple ranges. =?Utf-8?B?bWlrZQ==?= Microsoft Excel Worksheet Functions 7 9th Aug 2007 04:55 PM
multiple statements updating a table with multiple values =?Utf-8?B?TWlsbGJyb29rIFNjaG9vbA==?= Microsoft Access Queries 2 23rd Feb 2007 01:53 PM
Multiple if statements with multiple conditions =?Utf-8?B?ZWdhcmNpYQ==?= Microsoft Excel Misc 4 29th Jan 2007 10:46 PM
Multiple VBA IF/Then Statements Emm100 Microsoft Excel Programming 4 1st Jul 2005 03:54 PM


Features
 

Advertising
 

Newsgroups
 


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