So this is my problem: I have a template sheet into which data is pasted. The amount of rows of data will always differ (I dont think it will ever be higher than 30, but I coded capacity of 103) After the data is pasted, the sub should set the print area and borders accordingly, but not to the last row of data, but to the last page that contains data. I wrote this ugliness and it seems to work. I do wonder if there is a way to do this without nesting IF statements (I will have to do this all over again for a much larger data set)
parow = wsp.Range("A" & Rows.Count).End(xlUp).row
If parow <= 15 Then
parow = 15
Else:
If parow <= 29 Then
parow = 29
Else
If parow <= 43 Then
parow = 43
Else
If parow <= 58 Then
parow = 58
Else
If parow <= 73 Then
parow = 73
Else
If parow <= 88 Then
parow = 88
Else
If parow <= 103 Then
parow = 103
Else
End If
End If
End If
End If
End If
End If
End If
With wsp.PageSetup
.PrintArea = "$A$1:$G" & parow
.PrintTitleRows = "$1:$1"
.Orientation = xlLandscape
.FitToPagesWide = 1
End With
Aucun commentaire:
Enregistrer un commentaire