+ Reply to Thread
Results 1 to 3 of 3

VBA to hide cells based on dropdown list using If/Else/Then

  1. #1
    Registered User
    Join Date
    07-30-2012
    Location
    Farmington, New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    14

    VBA to hide cells based on dropdown list using If/Else/Then

    Hello,

    Thanks for your time. I am currently trying to write a VBA that will hide a RANGE of cells based on the value of a drop down list. I.E., my dropdown list is in C18 and contains a list of 0-6 (number of dents). So, if the user selects say 2 dents, I want to hide cells A28:C43 (dent dimensions-an entire block of cells). I have a VBA written, but as of right now it is hiding the entire column, and I haven't figure out how to edit it for a range of cells and not just the column. Here is my code

    Please Login or Register  to view this content.

    If this is not enough information required, please let me know.
    Any help will be much appreciated. Thanks!

    ---------- Post added at 10:47 AM ---------- Previous post was at 09:58 AM ----------

    Is this even possible? When using Format>Visibility>Hide and Unhide, there is not option for hiding cells I know, but I'm hoping there's a way to put bounds on entirecolumn.hidden/entirerow.hidden.

    Thanks again.
    Attached Files Attached Files
    Last edited by JOHNROK; 07-30-2012 at 06:11 PM. Reason: added attachment

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: VBA to hide cells based on dropdown list using If/Else/Then

    @ JOHNROK

    Welcome to the forum.

    Please notice that code tags have been added to your post(s). The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at top of the page and read Rule #3.
    Thanks.

  3. #3
    Registered User
    Join Date
    07-30-2012
    Location
    Farmington, New Mexico
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: VBA to hide cells based on dropdown list using If/Else/Then

    Ok, so after working through this all morning, I have found that hiding individual cells is impossible (to my knowledge), however, I changed the format of my sheet around so that hiding an entire ROW is ok. I have also changed for a dropdown list to a combo box. With this, I am now able to hide individual rows and it is working perfectly, except I would like for it to run everytime I change the value in the combobox, and not have to open the macro everytime I change that value. So, here is the code, please let me know how I can get the macro to run automatically.

    Thanks again,

    Please Login or Register  to view this content.


    ---------- Post added at 04:13 PM ---------- Previous post was at 04:05 PM ----------

    I have solved it! So, the problem was I had writen the macro in VBA (ctrl+F11, right click sheet and view code), but I hadn't "assigned" the macro to the combo box by right clicking on the combobox and "assigning a macro". Hope this helps for anyone else with this question

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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