Pulling a range from a print area

mark hansen

Well-known Member
Joined
Mar 6, 2006
Messages
534
Office Version
  1. 2016
Platform
  1. Windows
I've done some searches but only came up with how to set a print area with VBA... I want to go the other way.

I have print area set and need to set that range into a range variable to use in a sub routine.

I'm using a loop to go through my sheets with charts and need to save those charts as a JPG file to display in SharePoint. Each chart has a print area set already so it can be printed to paper.

I am able to take a range, that "hard coded" within the code and save that range to a JPG file. But I need the to use the print area range.

I start out like:
Dim PA as range 'PA = print area

Then in the loop I have a case statement that looks at the worksheet name
Case "All"
xFileName = ws.name & ".JPG
with Sheet14 ' ("All" ws)
Call SaveAsJPG (.Range("BC30:BQ106"), PathtoSave, xfilename)
end with

You can see I use BC30:BQ106 as the range to have in the JPG. This is the print area for the sheet.
Can I set the established Print area and use that as range to send to the SaveAsJPG routine?
Thanks
Mark
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You mean something like this?
VBA Code:
Dim PA As Range
  
  Set PA = Sheets("Final Tallies").PrintArea
  
  ...
  
  Call SaveAsJPG(PA, PathtoSave, xfilename)
 
Upvote 0
Jeffery,
Thanks for your quick reply, I appreciate your answer.
Mark
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,739
Members
448,989
Latest member
mariah3

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