Beforeprint with multiple If then else statements
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:Y 22)=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 |
All times are GMT +1. The time now is 01:13 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com