View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Davies John Davies is offline
external usenet poster
 
Posts: 39
Default message flash if sheet incomplete before printing

Thanks for the code, however I might have misled you, the fields that need to
be completed, already have some data in them and these need to be overtyped.
I presume that your code checks to see if the cells are blank, but can I get
the message to pop up if some cells are already populated with speciifc data.
eg. Cell C1 = "Enter Reg. No.", cell C2 = "Enter Colour Code" etc.

Thanks again for any help

"Norman Jones" wrote:

Hi John,

Try:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("A1:C1") '<<==== CHANGE

If rng.Cells.Count Application.CountA(rng) Then
Cancel = True
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " '& SH.Name _
& " need to be completed!"
End If

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"John Davies" wrote in message
...
I have a sheet that requires certain fields to be filled in before
printing.
Is it possible to have a message pop up if any of the fields have not been
completed when I click on the print button.

Thanks in advance of any help.

John