VBA Code to Resize All Charts in a Worksheet in Excel

VBA code that you can use to resize all charts in a worksheet in Excel.

VBA Code:

Sub ResizeAllCharts()
    Dim ws As Worksheet
    Dim cht As ChartObject
    
    ' Set the worksheet you want to resize charts in
    Set ws = ThisWorkbook.Worksheets("Sheet1") ' Change "Sheet1" to the desired worksheet name
    
    ' Loop through each chart in the worksheet
    For Each cht In ws.ChartObjects
        ' Resize the chart to fit within the worksheet's range
        With cht
            .Width = ws.UsedRange.Width ' Adjust width to fit within the used range of the worksheet
            .Height = ws.UsedRange.Height ' Adjust height to fit within the used range of the worksheet
        End With
    Next cht
    
    ' Inform the user that the charts have been resized
    MsgBox "All charts in the worksheet have been resized!"
End Sub


Check All VBA Codes

Join Our Telegram Group

Join the TechGuruPlus Telegram group

Join Our WhatsApp Group

Join the TechGuruPlus WhatsApp group
Nazim Khan, founder of TechGuruPlus.com

— Founder & Editor, TechGuruPlus.com
[MBA in Finance]

Nazim Khan has spent over ten years working with Excel, Tally and office documentation in accounts, finance and MIS roles. He has been running TechGuruPlus.com since 2016, where he publishes free editable templates for office work, and the YouTube channel Business Excel. He has trained more than 50,000 people online. Every template on this site is built and checked by him before it is published.

Contact  Â·  Excel Course

Leave a Comment