+ Reply to Thread
Results 1 to 11 of 11

Looking for help tidying up Macro vba code / visible/non visible buttons

  1. #1
    Registered User
    Join Date
    08-21-2012
    Location
    Heckmondwike, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    54

    Looking for help tidying up Macro vba code / visible/non visible buttons

    After searching for some code to make a button visible dependent on cell values, I found some code on here that 'almost works'

    3 of the 6 buttons on the sheet could be visible at any time, would appreciate any help tidying up this code to allow.

    I thank you in advance for reading.

    Darren

    Code below:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    Maybe something like this:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    08-21-2012
    Location
    Heckmondwike, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    54

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    Thanks, just used that and it doesnt seem to work. I would only need the buttons to appear if the cell value where stated was Y, otherwise would not want the button to appear at all.

    Appreciate the help Jerry.

    Darren

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    The syntax given "should work", so I'd need to see your sheet and get a little more detail on using it before I can adjust that suggestion much.

    Click GO ADVANCED and use the paperclip icon to post up a copy of your workbook.

  5. #5
    Registered User
    Join Date
    08-21-2012
    Location
    Heckmondwike, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    54

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    Thanks Jerry,

    I have highlighted the cells that the code relates to.

    Don't believe relevant but row 28 will be hidden once I have the code working.

    Appreciate the help.

    Darren
    Attached Files Attached Files

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    The first most glaring error is the "Button" names are completely wrong in your example macro above. So, try this instead:
    Please Login or Register  to view this content.
    If I got it backwards, then change the <> in the code above to =

  7. #7
    Registered User
    Join Date
    08-21-2012
    Location
    Heckmondwike, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    54

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    Thanks Jerry, I changed the <> to = as you suggested.

    It currently works if I overwrite the "Y" in the cell addresses, ideally I needed the buttons to automatically be visible / non visible based on the cell results (which is a lookup) should that matter?

    Darren

  8. #8
    Registered User
    Join Date
    08-21-2012
    Location
    Heckmondwike, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    54

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    Is there a way to add to the code you gave me so that it forces a calulation?

    Darren

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    The worksheet_change event it triggered by manual changes on the sheet somewhere.

    If you switch to a worksheet_calculate event instead, then the code even gets a little shorter.

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    08-21-2012
    Location
    Heckmondwike, England
    MS-Off Ver
    Excel 2007, 2010, 2013
    Posts
    54

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    Perfect! bang on.

    Reputation added to!

  11. #11
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Looking for help tidying up Macro vba code / visible/non visible buttons

    I have marked this thread solved for you.
    In the future please select Thread Tools from the menu above and mark the thread as solved. Thanks.

+ 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