+ Reply to Thread
Results 1 to 4 of 4

Hide/Show other macro buttons with a macro button

Hybrid View

nohero Hide/Show other macro buttons... 06-15-2011, 03:20 PM
nohero Re: Hide/Show other macro... 06-15-2011, 03:25 PM
Chance2 Re: Hide/Show other macro... 06-15-2011, 03:35 PM
nohero Re: Hide/Show other macro... 06-16-2011, 09:24 AM
  1. #1
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Hide/Show other macro buttons with a macro button

    Hi guys, I have an existing macro button to hide/unhide columns A:K using this code:

    Private Sub Rectangle1_Click()
        Columns("A:K").Hidden = Not Columns("A:K").Hidden
    End Sub
    I would like this existing macro to also hide/unhide 2 other macro buttons on my sheet. Essentially, once I click my macro to unhide A:K, I would like 2 new macro buttons to appear on my sheet. These buttons will again disappear when I hit the macro again to hide A:K.

    As an extension to this, I have 2 other shapes to hide/show within this macro as well, these are not tied into their own macros however.
    Last edited by nohero; 06-16-2011 at 12:10 PM.

  2. #2
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Hide/Show other macro buttons with a macro button

    Oh, while I'm at it, I'd also like this all-encompassing macro to delete the info in cell D3 every time it's pushed if possible... with focus set to that cell.

  3. #3
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Hide/Show other macro buttons with a macro button

    You can use the Visible property of the command button (command1.visible = false) to hide or show on click just like the columns. Of course you need to replace the command1 with your button names.

    As for D3, you can just use the Select function for the range.

  4. #4
    Registered User
    Join Date
    05-27-2011
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2007
    Posts
    72

    Re: Hide/Show other macro buttons with a macro button

    Well, after a little playing around I eventually came to this, which works exactly how I had hoped.

    Private Sub Rectangle1_Click()
        Columns("A:K").Hidden = Not Columns("A:K").Hidden
            Sheets("Main").Shapes("Rectangle 4").Visible = Not Sheets("Main").Shapes("Rectangle 4").Visible
            Sheets("Main").Shapes("Rectangle 5").Visible = Not Sheets("Main").Shapes("Rectangle 5").Visible
            Sheets("Main").Shapes("Left Arrow 6").Visible = Not Sheets("Main").Shapes("Left Arrow 6").Visible
            Sheets("Main").Shapes("Left Arrow 7").Visible = Not Sheets("Main").Shapes("Left Arrow 7").Visible
                Sheets("Main").Range("D3:F3").ClearContents
        Sheets("Main").Range("D3:F3").Select
    End Sub
    This is of course the work of a very new user and therefore I'm sure there's a better or shorter way to accomplish the same thing. Does anyone have a suggestion on how to improve it?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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