+ Reply to Thread
Results 1 to 5 of 5

Hide a combo box (form control), based on a cell value - Excel 2010

  1. #1
    Registered User
    Join Date
    07-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    3

    Hide a combo box (form control), based on a cell value - Excel 2010

    Hi guys

    I'm TOTALLY new to this.

    I am using Excel 2010

    I have a worksheet called "Price Calculator", In it are 4 form control combo boxes:

    1) "Drop Down 3", linked to cell $A$11
    2) "Drop Down 11"
    3) "Drop Down 12"
    4) "Drop Down 13"

    (I've got these names from the section to the left of the formula bar when the respective combo box is right clicked)

    What I'm trying to achieve is:

    whenever the cell link value to "Drop Down 3" <2 (i.e. when $A$11 <2) , I want the other 3 combo boxes to be automatically hidden
    and whenever $A$11 >= 2, for them to reappear

    Could someone please help me with the VBA code? And where do I put this code exactly? (in case I've been doing that bit wrong)

    I have tried everything I can find on the internet, but nothing seems to trigger a change event

    Would really appreciate your help )

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Hide a combo box (form control), based on a cell value - Excel 2010

    this macro at the sheet level could help you.
    Please Login or Register  to view this content.
    It is pretty simple, each time your selection change in that sheet, this macro is run and it check the value of cell A11 and hide or unhide the comboboxes.

    Now check carefully the names of your comboboxes as the one you gave are not good ones. You can't put space in a combobox name.
    With some minor adjustments, you should be able to get this macro work for you.
    Good luck.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    07-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    3

    Re: Hide a combo box (form control), based on a cell value - Excel 2010

    Hi and thanks for your help.

    The Combo Box Names are exactly as they appear in the section to the left of the formula bar when the respective combo box is right clicked

    I tried the code that you offered by right clicking the sheet tab and "view code" and pasting it onto the white coding area of the correct worksheet, and it returns an error "object required".

    Any ideas?

  4. #4
    Registered User
    Join Date
    07-09-2015
    Location
    London, England
    MS-Off Ver
    2010
    Posts
    3

    Re: Hide a combo box (form control), based on a cell value - Excel 2010

    Quote Originally Posted by p24leclerc View Post
    this macro at the sheet level could help you.
    Please Login or Register  to view this content.
    It is pretty simple, each time your selection change in that sheet, this macro is run and it check the value of cell A11 and hide or unhide the comboboxes.

    Now check carefully the names of your comboboxes as the one you gave are not good ones. You can't put space in a combobox name.
    With some minor adjustments, you should be able to get this macro work for you.
    Good luck.

    THIS IS NOW SOLVED

    Your code above returns an error, and when it doesn't, it simply does not trigger an event.

    The names I offered of the Combo Boxes are totally exactly right

    The problem is when a link to a combo box changes value, this does NOT trigger a change or selection change event.

    The following works:

    Private Sub Worksheet_Calculate()
    Dim ws As Worksheet

    Set ws = Sheets("Price Calculator")

    If Range("A11") < 2 Then
    ws.Shapes("Drop Down 11").Visible = False
    ws.Shapes("Drop Down 12").Visible = False
    ws.Shapes("Drop Down 13").Visible = False

    Else
    ws.Shapes("Drop Down 11").Visible = True
    ws.Shapes("Drop Down 12").Visible = True
    ws.Shapes("Drop Down 13").Visible = True

    End If

    End Sub


    Thanks again for your help, it was the start of my journey!

  5. #5
    Forum Contributor
    Join Date
    08-09-2012
    Location
    British Columbia
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Hide a combo box (form control), based on a cell value - Excel 2010

    Link to cross post

+ 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. Code works with Combo Box-Form Control, but not with Combo box - ActiveX Control
    By nangys in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-01-2014, 08:51 AM
  2. [SOLVED] Excel 2010 VBA – Combo Box Options– Clear cell/box in 2nd Combo when 1st Combo selected
    By theshybutterfly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-17-2013, 07:25 PM
  3. [SOLVED] Hide/Unhide Rows based on Combo Box (form control)
    By JimExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-01-2013, 09:38 AM
  4. [SOLVED] Hide Rows With Combo Box (Form Control)
    By needexcelhelp123 in forum Excel Programming / VBA / Macros
    Replies: 26
    Last Post: 09-13-2012, 04:10 PM
  5. Excel 2010 Combo box ActiveX control for the whole matrix table
    By Jungl3b0y in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-29-2012, 01:21 AM

Tags for this Thread

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