Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Print All Charts That are in a Worksheet


Bookmark and Share

This macro will print all of the embedded charts which are on the current active worksheet. Each chart will be printed on a separate page.
Where to install the macro:  Module

Print All Embedded Charts in a Worksheet

Sub PrintEmbeddedChartsinWORKSHEET()

'Prints all embedded worksheets that are on the active worksheet
'
     Dim ChartList As Integer
     Dim X As Integer
     ChartList = ActiveSheet.ChartObjects.Count
     For X = 1 To ChartList
         ActiveSheet.ChartObjects(X).Select
         ActiveSheet.ChartObjects(X).Activate
         ActiveChart.PrintOut Copies:=1
     Next
End Sub

Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Macro To Automate : A.) Saving Of Open Worksheet As New Excel File, B.)print Command To Print 2 Copies Each With Different Footer, And Some More Queries:) - Excel

View Content
All for the same file
a.) I have an invoice template in one excel file in which I fill in data, out of which some of it auto fills as it is linked to another excel file in which the master data is stored and updated. I wish to edit this invoice "template" (if u may call it that) and once I am done, I wish to click on the Print Macro enabled button that will print 2 copies. (i) 1st Copy with "Customer Copy" and (ii) 2nd Copy with "Merchant Copy" inserted at the bottom
b.)Then I would like to have another Macro enabled button which would:
-Save existing open Worksheet(which has just been printed) as a new Excel file with only the values (no Formalae nor Linking) , retain the exact formatting in the new file (column width etc.), and derive the filename from a cell value from the existing open sheet(edited template) [which will not be present in the new file as it will be out of print area] (the cell is on the far right on the sheet), Close the new file created to a designated folder, and keep the "template" open. Template should be open with the last edited info in order to key in the next chronological invoice no. (Don't know how to automate Invoice Numbers in this scenario, incrementation of the Invoice no. upon the event of Save as New file is daunting!)
c.)I also would like to be able to display numbers in Number Format, but as 001, or 01, or 00009 if that is the way I want to display it. For some reason, in Number format, it will display these values as 1,1 and 9 resp. How do I do that?
d.)Autocomplete! I know I know everyone seems to ask this same question but seriously is it possible? I have drop downs for Names and Products, and one has to keep manually scrolling down, is there a way to atleast be able to put in the first letter and have all records starting with the 1st letter displayed? Or is using the combobox with setting the property to autocomplete the only solution? But I wasn't completely able to do that either!
e.) Well I 've been able to achieve everything in bits and pieces (with my limited VBA knowledge) , but not been able to make all the functionalities work together at once!
Any help would be highly highly appreciated!
Thanks a million for giving it a read atleast ! ( I know I wrote a lot)
Warm Regards,
Sailee

How To Print Word Doc Automatically Every Time I Print A Worksheet - Excel

View Content
How can I set up a funtion or setting so that each time I print a specific worksheet in excel it automatically prints a seperate word document.

I have several worksheets of pricing quotes for different products and I would like to print the corresponding information about the product each time I print the individual worksheet.

Anyone have any pointers?

Using Vba To Print Charts - Excel

View Content
So the main user of a charting tool I made asked me about printing. Is there a way that I can run code before print? I would like to reorganize the sheet for printing so that only pertinent information is added to the print que.

Print Charts - Excel

View Content
Hello,

I need some help with printing charts. I have a workbook with several worksheets. Some (but not all) worksheets contain charts alongside the data. I would like to be able to print just the charts, two per page, the same size, hopefully just by clicking a button. Several people open the workbook and the charts on the sheets are moved and resized.

Is there anybody out there that can help?

Thanks,
Mark

Print Charts Via Dialog Box - Excel

View Content
I have this code which is kind of what I want. I am using it as a good explaination as to what I want to do as well as a starting point. I got it from "The Spreadsheet Page" It checks all the sheets in a workbook loads a dialog box and lists all the sheets with data in with a check box with an option to print them.

What I want is something very similar but checks for graphs. Obviously if there is a graph I would like it listed, so there is no need to check for data I think. I only have my graphs on a sheet named very originally "Graphs". So I don't think the code would need to check each sheet as this is doing.
Code:

Sub SelectSheets()
    Dim i As Integer
    Dim TopPos As Integer
    Dim SheetCount As Integer
    Dim PrintDlg As DialogSheet
    Dim CurrentSheet As Worksheet
    Dim cb As CheckBox
    Application.ScreenUpdating = False

 '   Check for protected workbook 
    If ActiveWorkbook.ProtectStructure Then
        MsgBox "Workbook is protected.", vbCritical
        Exit Sub
    End If

 '   Add a temporary dialog sheet 
    Set CurrentSheet = ActiveSheet
    Set PrintDlg = ActiveWorkbook.DialogSheets.Add

    SheetCount = 0

 '   Add the checkboxes 

    TopPos = 40
    For i = 1 To ActiveWorkbook.Worksheets.Count
        Set CurrentSheet = ActiveWorkbook.Worksheets(i)
 '       Skip empty sheets and hidden sheets 
        If Application.CountA(CurrentSheet.Cells)  0 And _
            CurrentSheet.Visible Then
            SheetCount = SheetCount + 1
            PrintDlg.CheckBoxes.Add 78, TopPos, 150, 16.5
                PrintDlg.CheckBoxes(SheetCount).Text = _
                    CurrentSheet.Name
            TopPos = TopPos + 13
        End If
    Next i

 '   Move the OK and Cancel buttons 
    PrintDlg.Buttons.Left = 240

 '   Set dialog height, width, and caption 
    With PrintDlg.DialogFrame
        .Height = Application.Max _
            (68, PrintDlg.DialogFrame.Top + TopPos - 34)
        .Width = 230
        .Caption = "Select sheets to print"

    End With

 '   Change tab order of OK and Cancel buttons
'   so the 1st option button will have the focus 
    PrintDlg.Buttons("Button 2").BringToFront
    PrintDlg.Buttons("Button 3").BringToFront

 '   Display the dialog box 
    CurrentSheet.Activate
    Application.ScreenUpdating = True
    If SheetCount  0 Then
        If PrintDlg.Show Then
            For Each cb In PrintDlg.CheckBoxes
                If cb.Value = xlOn Then
                    Worksheets(cb.Caption).Activate
                    ActiveSheet.PrintOut
 '                   ActiveSheet.PrintPreview 'for debugging 

                End If
            Next cb
        End If
    Else
        MsgBox "All worksheets are empty."
    End If



I have tried to adjust the various lines to relate to charts instead of sheets but was getting in a right kerfuffle. Whats more I have only just mastered the art of refering to sheets nevermind charts. I never dealt with dialog boxes.


This does seem a pretty big ask I know you like us to at least have try, but I know I will spead days on this without any help.

Thanks a lot, this will save my sanity if nothing else.
Partjob

Print Charts But Not Figures - Excel

View Content
If one a particular sheet the page setup shows you are spanning 2 printable pages of A4, 1 sheet with the charts on and the other with the data, can you tell excel to print the charts only but still keep the data visible? This would need to apply to a whole workbook where this situation applies on many sheets.

Print 4 Charts On 1 Page (vba) - Excel

View Content
Had a quick search but to no avail and my brain's not up to speed yet - maybe not enough caffeine yet! Anyhoo - any ideas?

Print Charts From Excel Using Vba - Excel

View Content
I have a project that requires the user to print 5 charts from excel. I want to automate the process as follows:

The user downloads the excel file to their hard drive

The user opens the file

A message box appears on sheet 1 and says "click yes to print the 5 charts or cancel"

If the user cancels, the message box is erased and only sheet 1 is visisble

If the user clicks on "yes" then the 5 charts are printed and the message box is erased and only sheet 1 is visible

How To Print All Charts On A Sheet - Excel

View Content
Hello,

I have a worksheet where I made a bunch of charts. Is there some way that I can print only the charts on a sheet, each on an individual page?

I don't want to select each one and press print, there are a lot.

Thanks,

-dif-

Print Embeded Charts - Excel

View Content
I have a macro that takes 1 worksheet of data and makes multiple sheets and embeds a chart on each sheet. The Macro works great. I need to make another for printing the charts, and still trying to learn loops.

Below is the chart name. I use this macro for multiple files so somethime only 10 sheets with charts on them and sometimes 40. There will be a chart on every sheet except for the sheets named "Index" and "Input".

ActiveSheet.ChartObjects("Chart 1").Activate

Thanks for your help

Random Tutorials
Remove #N/A Error Result from Empty VLOOKUP() Formulas
(Intermediate)
Lookups With MATCH() and INDEX() Functions
(Intermediate)
HLOOKUP() Function - Introduction
(Intermediate)
Function and Formulas Lookup in Excel
(Easy)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Absolute and Relative Cell References
   - & INDIRECT() Function Introduction

(Easy)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com