Pulling a range from a print area

mark hansen

Well-known Member
Joined
Mar 6, 2006
Messages
519
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
 

Some videos you may like

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Jeffrey Mahoney

Well-known Member
Joined
May 31, 2015
Messages
1,830
Office Version
  1. 365
Platform
  1. Windows
You mean something like this?
VBA Code:
Dim PA As Range
  
  Set PA = Sheets("Final Tallies").PrintArea
  
  ...
  
  Call SaveAsJPG(PA, PathtoSave, xfilename)
 

Watch MrExcel Video

Forum statistics

Threads
1,127,107
Messages
5,622,782
Members
415,927
Latest member
vedasinternational

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
Top