I know that this is a simple request - but I am having some trouble as I am still new to this.
Isn't there an easier way to perform this action?
Thanks and sorry in advance.Range("A1", Range("B500").End(xlUp)).Select Selection.Resize(Selection.Rows.Count, Selection.Columns.Count + 1).Select ActiveSheet.PageSetup.PrintArea = Selection.Address
Last edited by clemsoncooz; 02-09-2012 at 03:25 PM.
Should I just stay with it then. It doesnt pose any problems....just didnt know if I should clean it up since most of the advice I receive is "don't use select"
what about this
ActiveSheet.PageSetup.PrintArea = Range("A1", Range("B500").End(xlUp).Offset(, 1)).Address
Best Regards
MaczaQ
---------------------------------------------------------------------------------------------------------------------------
If you are satisfied with the solution(s) provided, please mark your thread as Solved
If you are pleased with my answer consider to use the Scales iconto rate it - This way you will add me some reputation points ... thanks in advance.
yea, yea thats what I was talking about. That does solve my question....but now that I run that code, I realize my question wasn't asked correctly because while your code is correct, it doesnt work correctly on my sheet because of the layout.
The resulting print area is (2) rows off and here is why.
I chose Column B because B31 to G33 is a merged cell. I am offsetting 1 column because I have data in G, but NOT H, and I need my print aread to extend to H. So when you offset 1 column from the merged cell of B31:G33, the result is H31. NOT H33, therefore it is off by (2) rows.
Know how to fix?
so try to useor attach your workbook with dummy data to show me your sheet structureActiveSheet.PageSetup.PrintArea = Range("A1", Range("B500").End(xlUp).Offset(2, 1)).Address
Best Regards
MaczaQ
---------------------------------------------------------------------------------------------------------------------------
If you are satisfied with the solution(s) provided, please mark your thread as Solved
If you are pleased with my answer consider to use the Scales iconto rate it - This way you will add me some reputation points ... thanks in advance.
Got it.
Thank you so much for your help!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks