excel: no blank

G

George

Hi,
I am looking for a macro before print to verify if specify cell is filled
with values..
Thanks.
George...
 
G

Guest

Copy the following code into the workbook's code module. To get to the right
place: right-click on the Excel icon to the left of the word "File" in the
Excel menu and choose [View Code] from the popup list. Copy the code below
into it and modify it to use the correct sheet name and cell that needs to
have data in it before it can be printed.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If IsEmpty(Worksheets("Sheet1").Range("A1")) Then
Cancel = True ' cancel printing
'don't print if the cell on the sheet is empty
'could put a message as:
MsgBox "No entry on sheet 'Sheet1', cell A1"
End If
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