I have a spreadsheet with 58 columns of potential data. I have used the
"sniplet" that Frank posted to another user that gives the print area based
upon the number of rows utilized, so the print area is not a problem. I have
tried tailoring the samples to remove blank columns, but I cannot get the
macro that would let me print out only those columns that have a value
greater than 0. Ideally, the macro would hide those columns with zero
balances, print, then unhide those same columns. Any suggestions?
> I have a spreadsheet with 58 columns of potential data. I have used
> the "sniplet" that Frank posted to another user that gives the print
[quoted text clipped - 4 lines]
> would hide those columns with zero balances, print, then unhide those
> same columns. Any suggestions?
If I understand the problem correctly (which isn't all that likely
considering I've been drinking...) then this sort of thing may be what
you're looking for:
Sub HideNilColumns()
columnsum = WorksheetFunction.Sum(Range("A1:A65535"))
If columnsum > 0 Then Columns("A:A").EntireColumn.Hidden = True
End Sub
You would obviously have to repeat the check for each relevant column and
add the appropriate code to unhide things afterwards. There's also a
possibility that the sum will equal zero if you have negative numbers which
exactly contra the positives. In this case, extra checks would need to be
added (perhaps by taking the absolute values of all the numbers in the
column? Not sure).
Paul C,
--
Wolf - 27 Dec 2004 14:49 GMT
Thank you Paul. I was able to use what you suggested.
Thanks Again.
> > I have a spreadsheet with 58 columns of potential data. I have used
> > the "sniplet" that Frank posted to another user that gives the print
[quoted text clipped - 23 lines]
> Paul C,
> --