Results 1 to 4 of 4

Thread: Set Chart size using VBA

  1. #1
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14

    Set Chart size using VBA

    Hi All,

    I need a function which change the height and width of all the charts in the active sheet.

    Thanx in Adavance.

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi,

    Code:
    Sub FixChartSize(ByVal cHeight As Single, cWidth As Single, Optional ByRef Chart_Object As ChartObject, Optional ByRef Sht As Worksheet)
        
        Dim i   As Long
        Dim c   As Long
        
        If Sht Is Nothing Then Set Sht = ActiveSheet
        
        If Chart_Object Is Nothing Then
            c = Sht.ChartObjects.Count
            If c Then
                For i = 1 To c
                    With Sht.ChartObjects(i)
                        .Height = cHeight
                        .Width = cWidth
                    End With
                Next
            End If
        Else
            With Chart_Object
                .Height = cHeight
                .Width = cWidth
            End With
        End If
        
    End Sub
    and call like

    FixChartSize 350, 700
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Senior Member
    Join Date
    Apr 2011
    Posts
    190
    Rep Power
    14
    Mohan
    You should check the chart sizer under cool code - you will luv it. You simply click on a chart - it then maximizes - you click again it minimizes.
    xl2007 - Windows 7
    xl hates the 255 number

  4. #4
    Senior Member LalitPandey87's Avatar
    Join Date
    Sep 2011
    Posts
    222
    Rep Power
    14
    Thanx for this useful function.
    Working!

Similar Threads

  1. Replies: 5
    Last Post: 04-18-2013, 02:30 AM
  2. VBA Validation List set
    By xander1981 in forum Excel Help
    Replies: 3
    Last Post: 02-15-2013, 04:07 PM
  3. set ListView on userform
    By Mahesh in forum Excel Help
    Replies: 3
    Last Post: 12-04-2012, 08:50 AM
  4. Size limitation on Uploads
    By alansidman in forum Den Of The Fox
    Replies: 1
    Last Post: 06-02-2012, 09:02 AM
  5. MS-Access Set Default Value of Column Using VBA
    By LalitPandey87 in forum Access Help
    Replies: 2
    Last Post: 04-08-2012, 09:40 AM

Posting Permissions

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