Format graphs across workbook

Big Bruiser

New Member
Joined
Dec 15, 2010
Messages
28
I have a workbook with several tabs and graphs on most tabs. The graphs contain titles and borders for presenation within Excel. However, when I copy and paste the graphs into PowerPoint, I prefer the graphs to not have a title and no borders. I would like to save myself the time of making this adjustment every time I create a PowerPoint. Is there a way to write a macro to reformat all of the graphs in the workbook? Ideally it would just hide the title, but it could also delete it. The borders just need to be reformatted to "no line."

I would appreciate any help!

Thanks!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try:

Code:
Sub Test()
    Dim ws As Worksheet
    Dim ch As ChartObject
    For Each ws In ActiveWorkbook.Worksheets
        For Each ch In ws.ChartObjects
            With ch.Chart
                .HasTitle = False
                .ChartArea.Border.LineStyle = 0
            End With
        Next ch
    Next ws
End Sub
 
Upvote 0
Only additional question I have is can the title be hidden or does it have to be deleted? When I run the macro it deletes the title, but if I want to toggle back and forth between showing and hiding the title, the original title is gone and it simply says "Chart Title." Is there a way to keep the old title?

My current code is

Private Sub CommandButton5_Click()
Dim ws As Worksheet
Dim ch As ChartObject

If CommandButton5.Caption = "Remove Titles" Then
For Each ws In ActiveWorkbook.Worksheets
For Each ch In ws.ChartObjects
With ch.Chart
.HasTitle = False
.ChartArea.Border.LineStyle = 0
End With
Next ch
Next ws
CommandButton5.Caption = "Show Titles"
ElseIf CommandButton5.Caption = "Show Titles" Then
For Each ws In ActiveWorkbook.Worksheets
For Each ch In ws.ChartObjects
With ch.Chart
.HasTitle = True
.ChartArea.Border.LineStyle = 1
End With
Next ch
Next ws
CommandButton5.Caption = "Remove Titles"
End If
End Sub
 
Upvote 0
Setting HasTitle to False effectively deletes the Title. Maybe you could set its Font and Border to the same colour as the ChartArea Fill.
 
Upvote 0
Here is my final solution. thanks!

Code:
Private Sub CommandButton5_Click()
    Dim ws As Worksheet
    Dim ch As ChartObject
    
    If CommandButton5.Caption = "Remove Titles" Then
    For Each ws In ActiveWorkbook.Worksheets
        For Each ch In ws.ChartObjects
            With ch.Chart
                If .HasTitle = True Then
                .ChartTitle.Font.Color = RGB(255, 255, 255)
                .ChartArea.Border.LineStyle = 0
                End If
            End With
        Next ch
    Next ws
        CommandButton5.Caption = "Show Titles"

ElseIf CommandButton5.Caption = "Show Titles" Then

    For Each ws In ActiveWorkbook.Worksheets
        For Each ch In ws.ChartObjects
            With ch.Chart
                If .HasTitle = True Then
                .ChartTitle.Font.Color = RGB(0, 0, 0)
                .ChartArea.Border.LineStyle = 1
                End If
            End With
        Next ch
    Next ws
        CommandButton5.Caption = "Remove Titles"
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,562
Messages
6,179,526
Members
452,923
Latest member
JackiG

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