"Data|filter|Show All" if your autofilter range is already showing all the
rows--or you don't have autofilter applied in that worksheet.
And I would stay way from using Selection in your code. Using selection means
that the results could vary depending on what was selected.
Maybe you could do all the hiding, printing and unhiding in your code.
I assumed that the quantity was in column A--and the only header row was 1.
Well since I'm having trouble with the sheet this minute, only thing I can say
about your macro is it didn't set the machine on fire.
Other than that all I got was a preview of a blank sheet.
But if I figure out what's going wrong with the sheet, [been fiddling with a
renegade ATI update from windows update] that torched my machine all day. I
haven't been able to even look at the grocery list today.
Option Explicit
Sub PrintOutSheet()
Dim wks As Worksheet
Set wks = ActiveSheet
Dim ColsToHide As Range
With wks
Set ColsToHide = .Range("C
,F:F,G:G")
I'm guessing the above code may be where the bug is because I have added
columns since the 1st macro code was written.
C = on hand, D = need, E = Buy, F = cost, G = completely blank, just a space
holder now, H, I, J, K and L should be added as columns to hide now.
'remove any existing autofilter dropdowns
the auto filter drop down I had was for on hand. If it found nothing, not much
use in running the macro.
Probably not necessary, but I hadn't figured out how to lock the top row while
scrolling the page down when the original macro was made.
.AutoFilterMode = False
.Range("a1").EntireColumn.AutoFilter _
I should change the range a1 above to E1 for BUY?
Field:=1, Criteria1:=">=1"
ColsToHide.EntireColumn.Hidden = True
.printout preview:=True
ColsToHide.EntireColumn.Hidden = False
'remove the filter
.AutoFilterMode = False
End With
End Sub
Yeah the change I made above to E1 worked to some degree.
The display and column headings 'Aisle, and need' are missing.
Here's your code as I rewrote it.
Option Explicit
Sub PrintOutSheet()
Dim wks As Worksheet
Set wks = ActiveSheet
Dim ColsToHide As Range
With wks
Set ColsToHide = .Range("C
,F:L")
'remove any existing autofilter dropdowns
.AutoFilterMode = False
.Range("E1").EntireColumn.AutoFilter _
Field:=1, Criteria1:=">=1"
ColsToHide.EntireColumn.Hidden = True
.printout preview:=True
ColsToHide.EntireColumn.Hidden = False
'remove the filter
.AutoFilterMode = False
End With
End Sub
Hmmm. Wonder why it doesn't show columns h, i, j, k and l ?
Well the code above works. Tnx...
Wonder where the headers to the columns went ?
Oh cripes. Wilma is looking like all this is going to be a waste of time. Be
lucky if there's a tree standing in this area, this time next week.
Another Hurricane Charlie headed in.
Hope Winn Dixie got smart and bought a backup generator since last year. Took 6
months for them to restock back to anything resembling normal.