Go back to required cell to fill

erutherford

Active Member
Joined
Dec 19, 2016
Messages
449
Have the basics down, now just trying to make it easier for the end user. Cell C21 is a required cell to be fill, not not a Message pops up. I would like the vba to take them right to that cell.
Here is the code I am using.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Cells(21, 3).Value = "" Then

MsgBox "License No. requires input before print"

Cancel = True

End If

End Sub

thanks in advance
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Have the basics down, now just trying to make it easier for the end user. Cell C21 is a required cell to be fill, not not a Message pops up. I would like the vba to take them right to that cell.
Here is the code I am using.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Cells(21, 3).Value = "" Then

MsgBox "License No. requires input before print"
Cells(21, 3).Select

Cancel = True

End If

End Sub

thanks in advance
Add the red highlighted code line shown above.
 
Upvote 0
Thanks for the reply. Since I am very new to vba, so not sure what to suggest

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Cells(21, 3).Value = "" Then

MsgBox "License No. requires input before print"
Cells(21, 3).Select
Cancel = True

End If

End Sub
 
Upvote 0
Did a simple test in a new workbook and it worked fine. Back to my project and I have the code assigned to "Workbook BeforePrint". Should I assign code to a "button" (macro)?
 
Upvote 0
Did a simple test in a new workbook and it worked fine. Back to my project and I have the code assigned to "Workbook BeforePrint". Should I assign code to a "button" (macro)?
It sounds to me like you may have other event code which is interfering with the BeforePrint event code.



Should I assign code to a "button" (macro)?
I don't see how that would do what you want (automatic reaction when a user tries to print).
 
Upvote 0
It sounds to me like you may have other event code which is interfering with the BeforePrint event code.




I don't see how that would do what you want (automatic reaction when a user tries to print).

Not sure why it worked, but added the code to a form control button in a new module and it worked. I didn't see any conflicts but at my level it doesn't mean there isn't . I am not sure if putting this in a module is proper. Still have a long road to go down in vba.

Thanks for your effort and at least now I know a little more vba than before!
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,734
Members
449,094
Latest member
dsharae57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top