Question Locked

Excel - print only fields with information entered

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
Have a few order forms in excel and would like to to print only those fields with date entered, not the entire order form. Anyone out there who can assist me with this- I think I need a macro.

4 replies

by fwang

Assuming the data in your order starts from row 2 and the date is in column B, if not, change startrow and datecol accordingly:

Sub AutoHide()
Dim r As Integer, startrow As Integer, datecol As Integer

startrow = 2
datecol = 2

Application.ScreenUpdating = False
For r = Cells.SpecialCells(xlLastCell).Row To startrow Step -1
If (Not IsDate(Cells(r, datecol))) Then
Rows(r).EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Cells.EntireRow.Hidden = False
End Sub

by nicci123

I need to do the same thing, and I got this code to work for my spreadsheet if I add dates to it, but can I do this using a number or text or the fact that the cell isn't blank instead?

Thanks,

Nic

Here is the code again just in case:

Assuming the data in your order starts from row 2 and the date is in column B, if not, change startrow and datecol accordingly:

Sub AutoHide()
Dim r As Integer, startrow As Integer, datecol As Integer

startrow = 2
datecol = 2

Application.ScreenUpdating = False
For r = Cells.SpecialCells(xlLastCell).Row To startrow Step -1
If (Not IsDate(Cells(r, datecol))) Then
Rows(r).EntireRow.Hidden = True
End If
Next
Application.ScreenUpdating = True

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

Cells.EntireRow.Hidden = False
End Sub

by tobif

You've revived an old thread to ask a question about how to do something like the same, but differently.
Ask your own question. (Especially that you even include the code, and/or you could give a link to the inspirational thread).
The reason I'm suggesting this is that your question indicates that your question is a bit unspecific and we may get a discussion about the most convenient way to handle your particular case.

This discussion is closed to new replies.