My Print area

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi,

How could I make the following code to select visible data rows starting from Row3 and onwards of the active sheet. My data column starts from column A to column R.

Code:
Sub PrintArea()
   ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.Address
End Sub

Any help on this could be kindly appreciated.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi. Try

Code:
Sub PrintArea()
   ActiveSheet.PageSetup.PrintArea = ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible).Address
End Sub
 
Upvote 0
Thanks for the code. But I want to exclude rows 1 to 2. How may I modify the code accordingly?
 
Upvote 0
Try

Code:
Sub PrintArea()
With ActiveSheet
    .PageSetup.PrintArea = .UsedRange.SpecialCells(xlCellTypeVisible).Offset(2).Address
End With
End Sub
 
Upvote 0
Thanks for the modification Peter. But the code selects all the columns from the avtice sheet. My intention is to include columns D to T in the print range.

How may I add this change.

Any help would be kindly appreciated.
 
Upvote 0
Try

Code:
Sub PrintArea()
Dim LR As Long
With ActiveSheet
    LR = .Range("D" & Rows.Count).End(xlUp).Row
    .PageSetup.PrintArea = .Range("D3:T" & LR).SpecialCells(xlCellTypeVisible).Address
End With
End Sub
 
Upvote 0
I have columns F,I,J & N (with data hidden) in my worksheet.

When I run the PrintArea macro it shows print gridlines starting from row 3 to the last data row. This is fine.

But it shows print gridlines between column D & E, G & I, L& M, O & T.

How could the code be changed so that it selects the print area from column D & E as a whole.

Note: Sorry for the reason that I couldn't mention I have hidden columns within the print range in my previous post.
 
Upvote 0
Perhaps something like this

Code:
Sub PrintArea()
Dim LR As Long
LR = Range("D" & Rows.Count).End(xlUp).Row
With ActiveSheet.PageSetup
    .Orientation = xlLandscape
    .FitToPagesWide = 1
    .FitToPagesTall = 1
    .PrintArea = Range("D3:T" & LR).SpecialCells(xlCellTypeVisible).Address
End With
End Sub
 
Upvote 0
Thanks for the modification Peter. Still I'm having the same problem as with your previous code. How could I over come this?
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,317
Members
452,905
Latest member
deadwings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top