See if the attached is what you have in mind. This code is assigned to a button on sheet one. It will hide columns, set the print area and print out, then show all columns and clear the print area.
Option Explicit
Sub Print_By_Date_Range()
Dim c As Range, strStart As String, strEnd As String, lcol As Long, lrow As Long
strStart = Sheet1.Range("D6").Value
strEnd = Sheet1.Range("F6").Value
lcol = Sheet1.Cells(7, Columns.Count).End(xlToLeft).Column
lrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False
If strStart = vbNullString Or strEnd = vbNullString Then
MsgBox "Please enter both a start and end date", vbExclamation
Exit Sub
End If
On Error Resume Next
For Each c In Range("D7", Cells(7, lcol))
If c.Value >= strStart And c.Value <= strEnd Then c.EntireColumn.Hidden = True
Next c
With Sheet1
.PageSetup.PrintArea = .Range("A7", Cells(lrow, lcol)).Address
.PrintPreview
.Columns.Hidden = False
.PageSetup.PrintArea = ""
End With
Application.ScreenUpdating = True
End Sub
Bookmarks