View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JE McGimpsey JE McGimpsey is offline
external usenet poster
 
Posts: 4,624
Default Printing with restrictions - VB

One way:

Put this in your ThisWorkbook code module:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Sheets("Sheet1").Range("A1:C1")
Cancel = Application.CountA(.Cells) < .Cells.Count
If Cancel Then _
MsgBox "You need to fill in cells " & _
.Cells.Address(False, False) & _
" of worksheet " & .Parent.Name & " before printing!"
End With
End Sub


In article ,
pgarcia wrote:

Hello again,
I looking to do the following; if cell A1, B1, and C1 are blank (no data)
then do not allow to print sheet. Given an error and indicate what cell(s) or
name of cell(s) needs to be filled.

Thanks