Forum Discussion

Javier_Fel91's avatar
Javier_Fel91
Copper Contributor
Mar 10, 2022
Solved

format change in graph

I would like to change the format of all my graphs, for example change the type from Calibri 10 to Arial 12 in all the graphs of my Excel book, Does any know if it is possible?
  • NikolinoDE's avatar
    NikolinoDE
    Mar 11, 2022

    Javier_Fel91 

    Why doesn't it work with the previously sent VBA code?

    It is for all diagrams in the active worksheet.

    Anyway here is some additional code from Internet, untested.

     

    Sub LoopThroughCharts()
    'PURPOSE: Loop through every graph in the active workbook
    'SOURCE: www.TheSpreadsheetGuru.com/The-Code-Vault
    Dim sht As Worksheet
    Dim CurrentSheet As Worksheet
    Dim cht As ChartObject
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Set CurrentSheet = ActiveSheet
    For Each sht In ActiveWorkbook.Worksheets
      For Each cht In sht.ChartObjects
        cht.Activate
        
        'Do something with the chart...
         
     With cht.Chart.ChartArea.Format.TextFrame2.TextRange.Font
        .Name = "Arial"
        .Size = 12
    End With
      
      
      Next cht
    Next sht
    CurrentSheet.Activate
    Application.EnableEvents = True
    End Sub

     

     

    NikolinoDE

    I know I don't know anything (Socrates)

     

Resources