View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Roger Whitehead Roger Whitehead is offline
external usenet poster
 
Posts: 32
Default Can printing in excel be blocked until data is in a certain cell?

If you open the VB Editor, look for your workbook in the project explorer
(usually on the left of the window). Select View, Project Explorer if in
doubt

Open the tree structure against your workbook name
Double-click the ThisWorkbook item - a code pane will open
Paste the code below into the Code pane
'-------<Snippet
Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Range("A1") < "You may print" Then
Cancel = True
End If
End Sub
'-------</Snippet

Edit the line beginning "If Activesheet..."
This code prevents printing of the active sheet if Cell A1 does not
contain "You may print" as the entire cell content.

Hope this sets you in the right direction
Roger
Shaftesbury (UK)








"Glen Loftus" <Glen wrote in message
...
I would like to have a feature in my worksheet that requires a cell to have
a
value entered into it before it is possible to print the page, can this be
done with a limited knowledge of Visual Basic programming?
If not perhaps a sample piece of code could be posted to achieve the
above.
I am using Excel 2003.
Thankyou