VBA move print area down 1 row from active cell

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
Hello,

I was just wondering what would be the code to adjust a print area down 1 row without using specific ranges?

I currently have a macro that finds the end of a table and adds a row for new data however I would like to expand the print area after I add the row by 1 row.

the only code I know is: ActiveSheet.PageSetup.PrintArea = "your range"

Any help would be appreciated.


Thank you :)

Carla
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,834
Office Version
2010
Platform
Windows
Not sure I understand exactly what you want. This offsets the print area by 1 row and adds 1 more row to it. Adjust to suit ...
Code:
Sub try()
With ActiveSheet
   .PageSetup.PrintArea = _
       .Range("Print_Area").Offset(1).Resize(.Range("Print_Area").Rows.Count + 1, _
       .Range("Print_Area").Columns.Count).Address
End With
End Sub
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
My mistake, the selected cell actually ends up just below the page break line so this code actually moves it one row lower than required. How could I adjust this code that it is even with the selected cell?
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
Nevermind, figured it out:

Code:
    With ActiveSheet   .PageSetup.PrintArea = _
       .Range("Print_Area").Offset(0).Resize(.Range("Print_Area").Rows.Count + 1, _
       .Range("Print_Area").Columns.Count).Address
End With
Thank you very much!!! :)
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
12,631
Office Version
365, 2010
Platform
Windows, Mobile
If you are Offsetting by 0 then you might as well just remove it :ROFLMAO:
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
16,834
Office Version
2010
Platform
Windows
Nevermind, figured it out:

Code:
    With ActiveSheet   .PageSetup.PrintArea = _
       .Range("Print_Area").Offset(0).Resize(.Range("Print_Area").Rows.Count + 1, _
       .Range("Print_Area").Columns.Count).Address
End With
Thank you very much!!! :)
You are welcome - thanks for the reply.
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
Actually this does not work. It is still moving down one row more than I need. Not sure how to adjust it that it moves to the selected cell...
 

willow1985

Active Member
Joined
Jul 24, 2019
Messages
499
Office Version
2019
Platform
Windows
Played around a bit and so far this is working:

Code:
   .PageSetup.PrintArea = _       .Range("Print_Area").Offset(2).Resize(.Range("Print_Area").Rows.Count - 1, _
       .Range("Print_Area").Columns.Count).Address
 

Watch MrExcel Video

Forum statistics

Threads
1,099,029
Messages
5,466,116
Members
406,467
Latest member
bpat83

This Week's Hot Topics

Top