Set print area of used cells macro

JamesMook

New Member
Joined
Feb 10, 2015
Messages
44
Hi, I have done a search of the forums and have found a few macros to set print area to only include used cells however they are not quite doing what i want.

I have a menu panel in cells A1 down to A4 and across to cells N1 and again down to N4.

I want the set print area macro to set from cells C5 across to N5 and then downwards to the last filled cell. I have borders around cells down to 1152 and some of these cells include formulas so need these not to be affected.

This macro will run from a button in the menu section so don't want an autorun macro button.

Hope this makes sense but if not please ask and i shall try to clarify. can anyone help?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Does this do what you want?

Code:
With Range("C5:N" & Rows.Count)
    LastRow = .Find(what:="*", after:=.Cells(1), LookIn:=xlValues, Lookat:=xlPart, _
        SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
End With

ActiveSheet.PageSetup.PrintArea = Range("C5:N" & LastRow).Address
 
Upvote 0
Does this do what you want?

Code:
With Range("C5:N" & Rows.Count)
    LastRow = .Find(what:="*", after:=.Cells(1), LookIn:=xlValues, Lookat:=xlPart, _
        SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False).Row
End With

ActiveSheet.PageSetup.PrintArea = Range("C5:N" & LastRow).Address

Excellent and yes it does. It's been doing my nut for days. lol Thanks
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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