+ Reply to Thread
Results 1 to 3 of 3

Hide a Chart with Form Control Buttons

Hybrid View

  1. #1
    Registered User
    Join Date
    08-13-2013
    Location
    Jakarta
    MS-Off Ver
    Excel 2013
    Posts
    38

    Hide a Chart with Form Control Buttons

    Hello,

    I have a sheet with 4 charts, how do I hide of the chart using form control button?

    My intention was to hide 3 pie charts when I click a button, and show only line graph, and another button to reverse it.

    I am not sure whether this question belongs to VBA threads or this one.

    Thank you, please find the sample file attached.
    Attached Files Attached Files

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,481

    Re: Hide a Chart with Form Control Buttons

    Add code to standard code module.

    Sub Button1_Click()
        With ActiveSheet
            .ChartObjects("Chart 1").Visible = True
            .ChartObjects("Chart 2").Visible = False
            .ChartObjects("Chart 3").Visible = False
            .ChartObjects("Chart 4").Visible = False
        End With
    End Sub
    Sub Button2_Click()
        With ActiveSheet
            .ChartObjects("Chart 1").Visible = False
            .ChartObjects("Chart 2").Visible = True
            .ChartObjects("Chart 3").Visible = True
            .ChartObjects("Chart 4").Visible = True
        End With
    End Sub
    Assign one macro to each button
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-13-2013
    Location
    Jakarta
    MS-Off Ver
    Excel 2013
    Posts
    38

    Re: Hide a Chart with Form Control Buttons

    Quote Originally Posted by Andy Pope View Post
    Add code to standard code module.

    Sub Button1_Click()
        With ActiveSheet
            .ChartObjects("Chart 1").Visible = True
            .ChartObjects("Chart 2").Visible = False
            .ChartObjects("Chart 3").Visible = False
            .ChartObjects("Chart 4").Visible = False
        End With
    End Sub
    Sub Button2_Click()
        With ActiveSheet
            .ChartObjects("Chart 1").Visible = False
            .ChartObjects("Chart 2").Visible = True
            .ChartObjects("Chart 3").Visible = True
            .ChartObjects("Chart 4").Visible = True
        End With
    End Sub
    Assign one macro to each button
    I tried this but without using With/End With function, and it failed. Thank you for the code!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Form control buttons creep
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-08-2014, 12:59 PM
  2. [SOLVED] How do i replicate Form Control Buttons in a spreadsheet?
    By msalib888 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2014, 11:09 PM
  3. Adding Form Control Buttons
    By wildlifegis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2012, 01:55 AM
  4. [SOLVED] Hide control buttons using VBA
    By Steffen_DK in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-30-2012, 09:49 AM
  5. Displaced control buttons after hide unhide
    By reinkonemann in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-11-2011, 10:36 AM
  6. Hide Control buttons, and make worksheet fullscreen.
    By abrunstad in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-29-2010, 02:43 PM
  7. How to insert NICE Form Control Buttons
    By sunilmulay in forum Excel General
    Replies: 3
    Last Post: 10-08-2009, 11:30 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1