I need to set a dynamic print area without using dates as the reference

By nicci123 ·
I was able to have a dynamic print area in excel using this code, and adding dates to my table, but is there a way for me to change the code slightly to allow a dynamic print area using numbers, text, or the fact the cell isn't blank instead of dates/ the IsDate function?



Here is the code from another post:

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
Application.ScreenUpdating = True

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

Cells.EntireRow.Hidden = False
End Sub

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Share your knowledge

Related Discussions

Related Forums