Results 1 to 7 of 7

ComboBox Loop to Hide Cells

Threaded View

ltjackson ComboBox Loop to Hide Cells 01-14-2016, 11:03 AM
ltjackson Re: ComboBox Loop to Hide... 01-14-2016, 12:20 PM
6StringJazzer Re: ComboBox Loop to Hide... 01-14-2016, 12:25 PM
ltjackson Re: ComboBox Loop to Hide... 01-14-2016, 12:35 PM
ltjackson Re: ComboBox Loop to Hide... 01-18-2016, 11:40 AM
6StringJazzer Re: ComboBox Loop to Hide... 01-18-2016, 12:23 PM
ltjackson Re: ComboBox Loop to Hide... 01-25-2016, 01:25 PM
  1. #1
    Registered User
    Join Date
    09-20-2015
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    16

    ComboBox Loop to Hide Cells

    Good morning!

    I've been developing a sheet for the amount of classes my business has over the year. I have a piece of code that seems to work well in filtering the data (I know auto-filters would be easier but they don't match the layout of the sheet) but I've ran into a problem. In the code below it's reading from 2 ComboBoxes currently but more will be added. If a combobox is left empty I'd like it to leave all the cells blank then move onto the next piece of code allowing multiple filtering levels. Where I'm running into the issue is in red below,

    Private Sub submit_filter_Click()
    Application.Calculation = xlManual
    Dim DataCriteria As String, i As Long, CountA As Long
    datacriteria_site = filter_nh_calendar.combobox_filter_site.Value
    datacriteria_lob = filter_nh_calendar.combobox_filter_lob.Value
    Rows("5:1004").EntireRow.Hidden = False
    CountA = 0
    
    Application.ScreenUpdating = False
    
    If datacriteria_lob = "" Then
        'code if null
    Rows("5:1004").EntireRow.Hidden = False
    Else
        'filters by LOB
    For i = 5 To 1004
        If Cells(i, 1).Value <> datacriteria_lob Then
        CountA = CountA + 1
        Rows(i).EntireRow.Hidden = True
        End If
    Next i
    End If
    
    If datacriteria_site = "" Then
        'code if null
    Rows("5:1004").EntireRow.Hidden = False
    Else
        'filters by site
    For i = 5 To 1004
        If Cells(i, 5).Value <> datacriteria_site Then
        CountA = CountA + 1
        Rows(i).EntireRow.Hidden = True
        End If
    Next i
    End If
    
    Application.Calculation = xlAutomatic
    Application.ScreenUpdating = True
        filter_nh_calendar.Hide
        Unload Me
    End Sub
    What I believe to be happening is that when I try and make a selection from "LOB" it accepts it but then see's that the "Site" field is empty and thus unhides everything. It works great for "Site" by itself because it's the last thing in the code I believe.

    I could be completely off base here but any assistance would be greatly appreciated.
    Thanks!
    Last edited by ltjackson; 01-25-2016 at 01:26 PM. Reason: Solved

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. combobox with For loop
    By vbhawsar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-24-2015, 04:10 AM
  2. Hide all the Worksheets except the one selected in Combobox
    By ankamshetti.nagaraj in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2014, 04:24 AM
  3. [SOLVED] ComboBox - Loop
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2012, 05:33 PM
  4. Hide Combobox based on Cell Value
    By savio21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-07-2011, 06:28 PM
  5. Combobox hide/unhide cells
    By excel_novice_83 in forum Excel General
    Replies: 2
    Last Post: 07-31-2010, 08:31 AM
  6. Hide TextBox/ComboBox on UserForm
    By bdb1974 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2010, 02:47 PM
  7. Combobox from range but hide some values
    By Maglor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-23-2009, 09:03 AM

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