+ Reply to Thread
Results 1 to 11 of 11

Hide/unhide button based on data validations

  1. #1
    Registered User
    Join Date
    09-08-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    74

    Hide/unhide button based on data validations

    Hi All,

    I am creating a disclaimer in one of my sheets.

    Cell I15 contains 'Are you a resident for tax purposes?' Cell N15 has the data validation list of Yes or No.

    Then I have a button below which covers rows18, 19 and 20.

    Is there a way I can have this button hidden until Cell N15 = Yes??

    I have tried to read other posts for this but was not able to apply that to my sheet.

    Thank you in advance for all your help.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/unhide button based on data validations

    Hello Jazzy Max,

    Copy this macro to the worksheet that has cell "N15". This macro is for a Forms button on the worksheet.
    Please Login or Register  to view this content.
    How to Save a Worksheet Event Macro
    1. Copy the macro using CTRL+C keys.
    2. Open your Workbook and Right Click on the Worksheet's Name Tab for the Worksheet the macro will run on.
    3. Left Click on View Code in the pop up menu.
    4. Paste the macro code using CTRL+V
    5. Make any custom changes to the macro if needed at this time.
    6. Save the macro in your Workbook using CTRL+S
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    09-08-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Hide/unhide button based on data validations

    Hi Leith,

    I have pasted the code and changed N15 to L13. But what it is doing at the moment is that once the button (in my case is "Bevel 6") is hit only then are the cells showing drop down lists.

    Otherwise they are not.

    Also, with the codes here is what I have:

    PHP Code: 
    Sub Workbook_Open()

        
    Msgbox "Please enable macros before proceeding"
       
    End Sub

    Private Sub Worksheet_Open()
        
    ActiveWindow.Zoom 80
    End Sub

    Private Sub Worksheet_Change(ByVal Target As Range)

      If 
    Target.Cells.Count 1 Then Exit Sub

      
    If Target.Address "$L$13" And Target.Value "Yes" Then
         ActiveSheet
    .Buttons("Bevel 6").Visible True
      
    Else
         
    ActiveSheet.Buttons("Bevel 6").Visible False
      End 
    If
      
    End Sub 
    The first code is a Msgbox that should appear as soon as the workbook is open. But it doesn't any ideas??

    Thank You for replying

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/unhide button based on data validations

    Hello Jazzy Max,

    The macro expected you were using a command button from the Forms Toolbar - not an Auto Shape.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-08-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Hide/unhide button based on data validations

    Great!! worked well.

    Last question the other codes I have above it, for instance the msgbox. How come that wont work? Is my wording correct?

    I want the msgbox to pop up as soon as the workbook is open.

    And the only field I have unlocked is L13 yet and everything is locked, yet when I open the book in its locked stated it has some other cell selected??

    Once I press enter it goes to L13..

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/unhide button based on data validations

    Hello Jazzy Max,

    Can you post your workbook? It will be easier to determine what is happening.

  7. #7
    Registered User
    Join Date
    09-08-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Hide/unhide button based on data validations

    ok here it is.

    I have only uploaded the relevant sheet, is that ok? or you prefer the whole workbook?

    Anyway, when the workbook is opened, the following should happen:

    -A Msgbox should pop up saying: Please enable macros etc..
    -Auto zoom to 80%

    BUT what is happening is Cell C3 is selected for no reason at all! it is totally irrelevant.

    Thanks Leith I really really appreciate your help. This is due in about 3 hours and this is all that I am stuck on.
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/unhide button based on data validations

    Hello Jazzy Max,

    I didn't look at your profile. You are using Excel 2007, which I don't have and neglected to mention. You will have to post a copy in "97-2003" format before I can open it. Even the mods make mistakes.

  9. #9
    Registered User
    Join Date
    09-08-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Hide/unhide button based on data validations

    Not a problem at all

    I have just saved it in 97-2003 mode. A lot of 'loss of functionality' things came up so I am not sure that you will be able to see what I really want to show.

    Here we go..
    Attached Files Attached Files

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Hide/unhide button based on data validations

    Hello Jazzy Max,

    Whatever functionality was lost didn't effect the original problem. I rewrote the Workbook_Open() macro and delete two worksheet event routines that duplicated the open event. Here is the macro which has been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    09-08-2009
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    74

    Re: Hide/unhide button based on data validations

    Hi Leith,

    Its cool now, I played around a bit tried to read and understand what each line means.

    I didn't have the code in the 'This Workbook' section.

    You have been great, thank you very much for your assistance reps added

+ 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