• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Stop Print command button if there are blank cells

sprlvlyldy

New Member
Hi,

this site has definately been my go to site. I am so new to VBA. I have been trying to figure this out for the past couple hours and decided to give in and ask the great minds on here.


I have a command button on the bottom of my excel sheet for printing. I do not want the user to be able to print if there are certain blank cells. This is the code I have kind of pieced together, which I know is completely wrong.


Private Sub Workbook()


If IsEmpty(B2, B3, B4) Then

CommandButton1.Disabled

MsgBox "A value is required before printing form."

Else

MsgBox ("Form is complete. Please route for signature.")

End If

End Sub


Can someone please help me figure out my errors? Do I need to include the sheet name in here somewhere (which is just Sheet1)?


Thank you in advance!

Sprlvlyldy
 
yes, and they are merged with other cells, so I don't know if that makes a difference.

So I merged cells B2:G2, B3:G3 and B4:G4.
 
Hi ,


The following segment works , I think. Try it out and let us know.


Private Sub temp()

Sheets(1).Activate

Sheet1.CommandButton1.Enabled = True

If IsEmpty(Range("B2")) And IsEmpty(Range("B3")) And IsEmpty(Range("B4")) Then

Sheet1.CommandButton1.Enabled = False

MsgBox "A value is required before printing form."

Else

MsgBox ("Form is complete. Please route for signature.")

End If

End Sub


Narayan
 
Back
Top