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
 
Try this:

I modified Ricks script just a little. Telling the user why we stopped the script:

Code:
Private Sub CommandButton1_Click()
  If Cells(21, 3).Value = "" Then
    MsgBox "License No. requires input before print"
    Cells(21, 3).Select
    
    Cancel = True
    MyValue = InputBox("Enter License Plate Info")
    If Len(Trim(MyValue)) Then
      Range("C21").Value = MyValue
    Else
      MsgBox "Hello we told you a License No.  is required" _
      & vbNewLine & "And you failed to enter one." _
      & vbNewLine & "So we are just going to end this script": Exit Sub
    End If
  End If
  
  Range("A1:I50").PrintOut
End Sub

OK
 
Last edited:
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
This script will give you a Input Box no matter if Cells(21,3) has a value or does not have a value. So why is the Message Box needed?

That was suggested as a solution to require, that cell to be filled before printing. Now having gone through this exercise, I see your point as well. Looks like it works fine without it and I can just change the text to read " you forgot, bah, bah....

Certainly cleaner, which is always better
:)
 
Upvote 0
Glad we were able to help you. Come back here to Mr. Excel next time you need additional assistance.
That was suggested as a solution to require, that cell to be filled before printing. Now having gone through this exercise, I see your point as well. Looks like it works fine without it and I can just change the text to read " you forgot, bah, bah....

Certainly cleaner, which is always better
:)
 
Upvote 0

Forum statistics

Threads
1,215,655
Messages
6,126,050
Members
449,283
Latest member
GeisonGDC

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