Macro print range

  • Thread starter Thread starter Shawn
  • Start date Start date
S

Shawn

I have a spread sheet that I would like to print columns
D to J starting with row 10. The number of rows that
have information in them will be different every time. I
would only like to print the number of rows that have
data in them. Please help me with writting a macro to
preform this action. Thank you very much.
 
One way:

Public Sub PrintDtoJ()
Dim nLastRow As Long
Dim i As Long

nLastRow = 10
For i = 4 to 10
nLastRow = Application.Max(nLastRow, _
Cells(Rows.Count, i).End(xlUp).Row)
Next i
With ActiveSheet
.PageSetup.PrintArea = "D10:J" & nLastRow
.PrintOut
End With
End Sub
 
Back
Top