I wish to write a vba script I can run for a spreadsheet in MS Excel that only prints only the rows for a column (let's say columnd) where the cells are not null (or zero).
The reason for this is that the rows total more than 100, and printing things out for only 20 actually needed entries seem silly.
Before anyone asks, MS Access is not an option.
Ok, I really stumbled on this one.
A friend got me through the hurdle. And walked me through it.
So here goes. Design the button, edit the code for it
here's the code for mine
rivate Sub CommandButton1_Click() Dim i, j As Integer ActiveSheet.Unprotect i = 2 j = 2 Do Do While Cells(j, 15) = "" And Cells(j, 1) <> "ENDOFLIST" j = j + 1 Loop If j > i Then Range("A" & i & ":P" & j).Select Selection.EntireRow.Hidden = True End If i = j Do While Cells(j, 15) <> "" And Cells(j, 1) <> "ENDOFLIST" j = j + 1 Loop Range("A" & i & ":P" & j).Select Selection.EntireRow.Hidden = False i = j Loop Until Cells(i, 1) = "ENDOFLIST" ActiveSheet.PageSetup.PrintArea = "$A$1:$p$" & i ActiveWindow.SelectedSheets.PrintPreview Range("A1:P" & i).Select Selection.EntireRow.Hidden = False End Sub
'it's dynamic to the active sheet, so wow I really was impressed with the simplicity of it.
Got an answer for JtotheA? Would you like to comment on the posted answers, or vote for the one which you think is the best?
Sign up for a free account, or sign in (if you're already a member).
Other people asked questions on similar topics, check out the answers they received:
Other people asked questions on various topics, and are still waiting for answer. Would be great if you can take a sec and answer them