AusSteelMan
Board Regular
- Joined
- Sep 4, 2009
- Messages
- 208
Hi everyone,
I would like to request some help with the following problem.
I would like to use some code to set a non contiguous print area using columns A to E and K to AE. The number of rows is determined by finding the last row used.
Here is the code I am up to at the moment:
I get an error at the following line
When I watched the code execute, the LeftRange was simply the contents of the Cell A1 and the RightRange was the contents of K1
(Which makes sense actually...I think anyway)
Previously I could get A to AE down to last row to work using
My preference is to be able to set the print area and manually print.
I know I can get the area to set, hide Cols F to J, print out and unhide cols as one code action, but the users want to be able to check before committing the print.
Can anybody offer any advice or help.
Thanks,
ASM
I would like to request some help with the following problem.
I would like to use some code to set a non contiguous print area using columns A to E and K to AE. The number of rows is determined by finding the last row used.
Here is the code I am up to at the moment:
Code:
Sub setprintarea()
Dim LeftRange As String
Dim RightRange As String
Dim LastRow As Integer
ActiveSheet.Unprotect
Application.ScreenUpdating = False
'ActiveWindow.FreezePanes = False
LastRow = ActiveSheet.UsedRange.Rows.Count
'ActiveSheet.PageSetup.PrintArea = "$A$1:$AE$" & LastRow
LeftRange = Range("a1, e" & LastRow)
RightRange = Range("k1, ae" & LastRow)
ActiveSheet.PageSetup.PrintArea = LeftRange & RightRange
Application.ScreenUpdating = True
'ActiveSheet.Protect
End Sub
I get an error at the following line
Code:
ActiveSheet.PageSetup.PrintArea = LeftRange & RightRange
When I watched the code execute, the LeftRange was simply the contents of the Cell A1 and the RightRange was the contents of K1
(Which makes sense actually...I think anyway)
Previously I could get A to AE down to last row to work using
Code:
ActiveSheet.PageSetup.PrintArea = "$A$1:$AE$" & LastRow
My preference is to be able to set the print area and manually print.
I know I can get the area to set, hide Cols F to J, print out and unhide cols as one code action, but the users want to be able to check before committing the print.
Can anybody offer any advice or help.
Thanks,
ASM