ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   conditional disable functions (https://www.excelbanter.com/excel-programming/315785-conditional-disable-functions.html)

Andre S

conditional disable functions
 
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

Tom Ogilvy

conditional disable functions
 
Private Sub Workbook_BeforePrint(Cancel As Boolean)
suppres_lines
if <condition then
Cancel = True
end if
End Sub

--
Regards,
Tom Ogilvy


"Andre S" <Andre wrote in message
...
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





All times are GMT +1. The time now is 09:11 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com