![]() |
Can printing in excel be blocked until data is in a certain cell?
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 |
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 |
Can printing in excel be blocked until data is in a certain ce
Thank you Roger,
I am absolutely staggered at how 5 lines of code can solve my dilemna. I think you've broken the ice with VB for me. :-) Have a great day. Glen Loftus "Roger Whitehead" wrote: 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 |
All times are GMT +1. The time now is 07:55 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com