+ Reply to Thread
Results 1 to 4 of 4

Macro to show a button?

  1. #1
    Registered User
    Join Date
    01-07-2006
    Posts
    26

    Macro to show a button?

    Is it possible to a worksheet that hides a command button, and then a macro is called, and allow the macro to unhide a command button?

    Example:
    Macro is run:
    If Cell A1 = 100 then borrower can see the command button
    if Cell A1 <> 100 then borrower can't see the command button

    Is this even possible using VBA?

  2. #2
    Forum Contributor
    Join Date
    06-01-2006
    Posts
    324
    Sure there is, try this:

    Sub Macro1()

    If ActiveSheet.Range("A1").Value = 100 Then
    ActiveSheet.Shapes("CommandButton1").Visible = True
    Else: ActiveSheet.Shapes("CommandButton1").Visible = False
    End If

    End Sub
    Last edited by Bearacade; 06-22-2006 at 01:12 PM.
    Google is your best friend!

  3. #3
    Brian G
    Guest

    RE: Macro to show a button?

    Here are some ideas:
    1) hide and unhide a row/column
    2) this is just a thought, but userforms have the .show method, and I'm not
    sure if that would apply to something like a command button offhand.
    3) use a drawing object and change the color from gray to no color.

    "Steach91" wrote:

    >
    > Is it possible to a worksheet that hides a command button, and then a
    > macro is called, and allow the macro to unhide a command button?
    >
    > Example:
    > Macro is run:
    > If Cell A1 = 100 then borrower can see the command button
    > if Cell A1 <> 100 then borrower can't see the command button
    >
    > Is this even possible using VBA?
    >
    >
    > --
    > Steach91
    > ------------------------------------------------------------------------
    > Steach91's Profile: http://www.excelforum.com/member.php...o&userid=30234
    > View this thread: http://www.excelforum.com/showthread...hreadid=554655
    >
    >


  4. #4
    JLatham
    Guest

    Re: Macro to show a button?

    You can simplify that even more to become a toggle switch by using this code

    ActiveSheet.Shapes("CommandButton1").Visible =
    Not(ActiveSheet.Shapes("CommandButton1").Visible)

    it will flip flop back and forth between Visible/Not Visible (True/False)
    each time it's called.

    "Bearacade" wrote:

    >
    > Sure there is, try this:
    >
    > If ActiveSheet.Shapes("CommandButton1").Visible = True Then
    > ActiveSheet.Shapes("CommandButton1").Visible = False
    > ElseIf ActiveSheet.Shapes("CommandButton1").Visible = False Then
    > ActiveSheet.Shapes("CommandButton1").Visible = True
    > End If
    >
    >
    > --
    > Bearacade
    >
    >
    > ------------------------------------------------------------------------
    > Bearacade's Profile: http://www.excelforum.com/member.php...o&userid=35016
    > View this thread: http://www.excelforum.com/showthread...hreadid=554655
    >
    >


+ 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