conditional disable functions

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

In a worksheet, I work with data in a table and the last colomn has a sum
function. that can be a value or 0. Because all rows that ends with sum = 0,
I want to suppress them when I print. Therefore I start a macro suppres_lines
that uses the filterfunction and all rows with value 0 are hidden. I placed
the macro under the Workbook folder

Private Sub Workbook_BeforePrint(Cancel As Boolean)
suppres_lines
End Sub

But it can also be, that under circumstances there is no row in the table at
all. (all rows are 0) Therefore I would have the possibilty to cancel the
printcommand. I tried a lot of things, like Exit sub, but after exiting this
BEFOREprint, the printcommand is still executed. Is there something that
cancels the action that would be taken after a before...(print/save/close)
action?

Andre S
 
Private Sub Workbook_BeforePrint(Cancel As Boolean)
suppres_lines
if <condition> then
Cancel = True
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

Back
Top