+ Reply to Thread
Results 1 to 2 of 2

Filtering through multiple checkboxes VBA

  1. #1
    Registered User
    Join Date
    12-01-2014
    Location
    Pennsburg, PA
    MS-Off Ver
    2010
    Posts
    10

    Filtering through multiple checkboxes VBA

    [URL="http://www.excelforum.com/excel-programming-vba-macros/1053432-multiple-checkboxes-to-filter-post3931935.html?highlight=#post3931935"]http://www.excelforum.com/excel-prog...t=#post3931935

    Downstream Integration Points3.xlsm

    I dont know what the rules are with this but i included the link to my last post that was at the time solved. Please let me know if I should just post onto that original thread.

    At the time I was looking for a way to filter column C by the caption listed in the checkbox in my userform frame on page 3 of a multipage. Now the filtering is in Column E instead of column C. I thought it would be as simple as changing the range from C:C to E:E but it is not actually filtering anything now.


    Private Sub cmdsave_Click()
    Dim myFilter() As Variant
    Dim c As Range
    ReDim myFilter(0)
    Dim ws As Worksheet
    Dim LR As Long
    Dim rng As Range, cel As Range

    Set ws = ActiveSheet
    With ws
    .AutoFilterMode = False
    LR = .Range("B" & .Rows.Count).End(xlUp).Row
    Set rng = Range("E7:E" & LR)
    End With

    For i = 1 To 22
    If Me.Controls("CheckBox" & i).Value = True Then
    Set c = Range("E:E").Find(Me.Controls("Checkbox" & i).Caption, , xlValues, xlPart, xlByRows, xlNext, False)
    If Not c Is Nothing Then
    myFilter(UBound(myFilter)) = Me.Controls("Checkbox" & i).Caption
    ReDim Preserve myFilter(UBound(myFilter) + 1)
    End If
    End If
    Next i
    If IsError(Application.Match("*", (myFilter), 0)) Then
    MsgBox "Either there are no Records for the Item Selected " & vbCrLf & _
    "or you didn't select an Item...Please Select an item"
    Exit Sub
    Else
    ReDim Preserve myFilter(UBound(myFilter) - 1)
    End If

    Application.ScreenUpdating = False
    ws.Rows(8 & ":" & LR).EntireRow.Hidden = True

    For i = LBound(myFilter) To UBound(myFilter)
    For Each cel In rng
    If InStr(Trim(cel.Value), myFilter(i)) > 0 Then
    If cel.EntireRow.Hidden = True Then
    cel.EntireRow.Hidden = False
    End If
    End If
    Next cel
    Next i
    Application.ScreenUpdating = True


    End Sub

  2. #2
    Registered User
    Join Date
    12-01-2014
    Location
    Pennsburg, PA
    MS-Off Ver
    2010
    Posts
    10

    Re: Filtering through multiple checkboxes VBA

    Please disregard this thread. I have solved this error with a simple mistake. "B" should be "D". Thank you.

+ 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. [SOLVED] Checkboxes on Cover tab and Multiple Filtering on separate tab
    By Vinyasa in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2013, 03:23 PM
  2. Checkboxes for Filtering have disappeared :(
    By JM17 in forum Excel General
    Replies: 9
    Last Post: 11-27-2013, 11:17 AM
  3. Replies: 2
    Last Post: 11-01-2013, 03:23 AM
  4. Filtering to multiple criteria via checkboxes in VBA
    By Viv_bot in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-11-2012, 04:41 AM
  5. Problems filtering data containing checkboxes???
    By nameyers in forum Excel General
    Replies: 1
    Last Post: 10-18-2007, 02:48 PM

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