VBA macros for Printing

Mabocat

Board Regular
Joined
Apr 20, 2011
Messages
74
This macro is to print a graph from a spreadsheet
Code:
Sub Print_Graph()
'
' Print_Graph Macro
'
'      Application.ScreenUpdating = False

    Application.Goto Reference:="AM_Graph"
    ActiveSheet.PageSetup.PrintArea = "$A$2:$DW$57"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
        IgnorePrintAreas:=False
    Range("A1").Select
    
    Application.ScreenUpdating = True

End Sub

Two things:-
even though I have set Screenupdate to false so it doesn't show selections etc, it still does - also see below
PrintArea is $A$2:$DW$57 but what if the area which has the range name of AM_Graph gets varied with an additional row - can I have the PrintArea also shown as AM_Graph?


When I go to print the data from two sheets - firstly Page 1 of Sheet 1, then all of Sheet 2 then page 2 of sheet 1, the screen flips back & forth between both sheets when I don't want it to.

Ron
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
First in your code it looks as though you have commented out the Application.ScreenUpdating = False line

Second if the area is variable then you could try either an offset method or .CurrentRegion.Select which will adjust to the cells that have content.
 
Upvote 0
First in your code it looks as though you have commented out the Application.ScreenUpdating = False line

Second if the area is variable then you could try either an offset method or .CurrentRegion.Select which will adjust to the cells that have content.

Trevor, what does this mean ? have commented out the Application.ScreenUpdating = False line



I will try the CurrentRegion.Select method


looks like I will have to obtain a book on VBA & the various words to use.
 
Upvote 0
Mabocat;

Where Trevor G says:
First in your code it looks as though you have commented out the Application.ScreenUpdating = False line

He is saying that you have preceded your 3rd line of code

Application.ScreenUpdating = False WITH AN APOSTROPHE " ' " - causing the code to NEGLECT the complete code line. OK?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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