Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    I have 7 graphs per worksheet on several worksheets. The graphs are the same on each worksheet, but relate to the applicable branches data.

    I have written code to do the job, but need it streamlined. It would be appreciated if you could assist.

    The code for sheet "Graph PE" is the same as sheet "Graph Uiten". I would like the code simplified so that it is repeated for each of the sheets. I have 13 worksheets with the same graphs, but for different branches, so only the data is different

    Code:
    Sub Print_Graphs()
    Application.ScreenUpdating = False
    Sheets("Graph PE").Select
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.SeriesCollection(1).Select
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 3").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 4").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 5").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 6").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    Sheets("Graph Uiten").Select
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.SeriesCollection(1).Select
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 3").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 4").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 5").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 6").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    Sheets("Graph Newton").Select
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.SeriesCollection(1).Select
    ActiveSheet.ChartObjects("Chart 2").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 3").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 4").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 5").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 6").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveChart.Axes(xlValue).MajorGridlines.Select
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveSheet.ChartObjects("Chart 7").Activate
    ActiveChart.PlotArea.Select
    ActiveWindow.SelectedSheets.PrintOut Copies:=1
    Application.ScreenUpdating = True
    
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    How about

    Code:
    Dim wsh As Worksheet
    Dim cho As ChartObject
    For Each wsh In ActiveWorkbook.Worksheets
      For Each cho In wsh.ChartObjects
    	cho.Activate
    	wsh.PrintOut
      Next cho
    Next wsh

  3. #3
    Bronze Lounger
    Join Date
    Feb 2008
    Posts
    1,423
    Thanks
    125
    Thanked 5 Times in 5 Posts
    Hi Hans

    Thanks for the help, much appreciated

    Regards

    Howard

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •