One last question on this project (I hope)....
I am setting up the print area for my data dependant on the number of sheets per page inputted by the user, the total range on the data (last column value contained in cell A21), and the number of columns to fit to a page.
See below...
I get an error 1004 on Set ActiveSheet.VPageBreaks(i).Location = Range(Cells(21, i).Value)
Also, this is someone else's code, so I guess I don't really get what is happening in that line anyways. Isn't that stepping over to the right? so if i=2 it is selecting from column B, etc...
Dim i As Integer
With ActiveSheet.PageSetup
.PrintTitleRows = "17:20"
.PrintTitleColumns = "$A:$Z"
.PrintArea = "$A$1:$" & Range("A21").Value & "$" & 21 + 5 * Range("L21").Value 'A21 has a text value of the column header
.Zoom = 100
.Zoom = False
.FitToPagesWide = Range("B21").Value 'B21 is the number of pages the user wants to print the data on (typically between 1 and 4)
End With
ActiveWindow.View = xlPageBreakPreview
If Range("B21").Value >= 2 Then
For i = 1 To Range("B21").Value - 1
Set ActiveSheet.VPageBreaks(i).Location = Range(Cells(21, i).Value)
Next i
End If
I am setting up the print area for my data dependant on the number of sheets per page inputted by the user, the total range on the data (last column value contained in cell A21), and the number of columns to fit to a page.
See below...
I get an error 1004 on Set ActiveSheet.VPageBreaks(i).Location = Range(Cells(21, i).Value)
Also, this is someone else's code, so I guess I don't really get what is happening in that line anyways. Isn't that stepping over to the right? so if i=2 it is selecting from column B, etc...
Dim i As Integer
With ActiveSheet.PageSetup
.PrintTitleRows = "17:20"
.PrintTitleColumns = "$A:$Z"
.PrintArea = "$A$1:$" & Range("A21").Value & "$" & 21 + 5 * Range("L21").Value 'A21 has a text value of the column header
.Zoom = 100
.Zoom = False
.FitToPagesWide = Range("B21").Value 'B21 is the number of pages the user wants to print the data on (typically between 1 and 4)
End With
ActiveWindow.View = xlPageBreakPreview
If Range("B21").Value >= 2 Then
For i = 1 To Range("B21").Value - 1
Set ActiveSheet.VPageBreaks(i).Location = Range(Cells(21, i).Value)
Next i
End If