Setting Print area Range
发布时间:2026-08-26 | 浏览:2
I have recorded a macro. Have a couple of issues with it. I would like to use an inputbox to select and set the "Print Area" Range. Title the box "Print Area". I have to use the "Picture" because of Chart graphis, can not use copy cells to do this.
Below is macro with notes. I'm fairly new at this and could use a little help.
Thanks in advance.
' Print Selected area!
Sheets("Sheet2").Select
ActiveSheet.Shapes.Range(Array("Picture 9")).Select 'First problem deleting pervious picture get an error here.
'Picture is different every time.
Sheets("Log ").Select
Range("A173:M212").Select 'Here I would like to have an inputbox to select and set range
' Also to set print range below
ActiveSheet.PageSetup.PrintArea = "$A$173:$M$212"
'Rest of it works properly. Will assign this macro to a button to print
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
Sheets("Sheet2").Select
ActiveSheet.Shapes.Range(Array("Picture 8")).Select
Range("A40").Select
ActiveSheet.Shapes.Range(Array("Picture 8")).Select
Range("A40").Select
ActiveSheet.Paste
ActiveSheet.Shapes.Range(Array("Picture 4")).Select
Selection.ShapeRange.LockAspectRatio = msoFalse
ActiveWindow.SmallScroll Down:=-6
Selection.ShapeRange.Width = 597.6
Range("A1:M107").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$M$107"
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Anonymous 2016-07-07T16:21:33+00:00 Thanks, for the help but not what I was looking for. Just want to modify my macro. By using the Select print area I take in the cells with information as well as a section of my chart object. Don't want the whole chart just sections of it. By setting the Select range I can print picture of what I need and paste it below the range on Sheet2, with other need information, pertaining to the section of the chart. Using print picture I can include all info. Then select and print sheet 2 as a full page to present. Thanks, Frank 0 comments No comments
Thanks, for the help but not what I was looking for. Just want to modify my macro. By using the Select print area I
take in the cells with information as well as a section of my chart object. Don't want the whole chart just sections of it.
By setting the Select range I can print picture of what I need and paste it below the range on Sheet2, with other need information, pertaining to the section of the chart.
Using print picture I can include all info. Then select and print sheet 2 as a full page to present.
Anonymous 2016-07-07T08:22:04+00:00 Hi, [update July 08, 2016] in the sample below we have three chart objects in active sheet Chart One from range A1:D4 value1 from range A1:B4 value3 from range A1:A4,D1:D4 pic1 set print area, each chart, separately. pic2 (chart One) pic3 (value1) pic4 (value3) vba macro Sub Chart_PrintArea() 'July 07, 2016 Dim cht As ChartObject Dim sRng As String With ActiveSheet For Each cht In .ChartObjects sRng = .Range(cht.TopLeftCell, cht.BottomRightCell).Address .PageSetup.PrintArea = sRng .PrintPreview Next cht End With End Sub the basic idea is from here.. http://www.mrexcel.com/forum/excel-questions/803161-get-underlying-range-address-chartobject-excel.html 0 comments No comments
[update July 08, 2016]
in the sample below we have three chart objects in active sheet
Chart One from range A1:D4
value1 from range A1:B4
value3 from range A1:A4,D1:D4
set print area, each chart, separately.
pic2 (chart One)
Sub Chart_PrintArea()
Dim cht As ChartObject
Dim sRng As String
With ActiveSheet
For Each cht In .ChartObjects
sRng = .Range(cht.TopLeftCell, cht.BottomRightCell).Address
.PageSetup.PrintArea = sRng
the basic idea is from here..
http://www.mrexcel.com/forum/excel-questions/803161-get-underlying-range-address-chartobject-excel.html