Excel 2003 - Code to print and/or delete

J

jdph40

I need help with code. With the code below, I want to be asked if I
want to delete the hours whether or not I print, but if I click "No"
to the print question, I'm not asked if I want to delete the hours.
Will someone please tell me what I need to add to my code?

Msg = "Do you want to print?"
Response = MsgBox(Msg, vbYesNo + vbQuestion)
If Response = vbYes Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Msg1 = "Do you want to delete the hours?"
Response1 = MsgBox(Msg1, vbYesNo + vbQuestion)
If Response1 = vbYes Then
Range("F3:H58").Select
Selection.ClearContents
Range("F45").Select
Else
Exit Sub
End If
End If

End Sub

Thanks!
JD
 
B

Bill Renaud

Try this (untested):

Msg = "Do you want to print?"
Response = MsgBox(Msg, vbYesNo + vbQuestion)
If Response = vbYes Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If '<==Move End If to here.

Msg1 = "Do you want to delete the hours?"
Response1 = MsgBox(Msg1, vbYesNo + vbQuestion)
If Response1 = vbYes Then
Range("F3:H58").Select
Selection.ClearContents
Range("F45").Select
Else
Exit Sub
End If '<==Delete one End If here.
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