Consulting

Results 1 to 4 of 4

Thread: Filtering on checkbox text

  1. #1
    VBAX Regular
    Joined
    Jun 2018
    Posts
    42
    Location

    Filtering on checkbox text

    Hi There,

    I have following code that uses the text of form controls checkboxes to filter a list if they are checked.

    I want to perform this exact same function but use activeX checkboxes and for the life of me I cant figure it out.

    Any help would be greatly appreciated.

    Dim arrList() As String, Cnt As Long
    
             Cnt = 0
            For Each CheckBox In ThisWorkbook.Sheets("Checkboxes").CheckBoxes
               If CheckBox.Value = 1 Then
                ReDim Preserve arrList(Cnt)
                arrList(Cnt) = CheckBox.Text
                Cnt = Cnt + 1
               End If
            Next
             Sheets("Sheet1").Range("$A$8:$S$10000").AutoFilter Field:=5, Criteria1:=arrList, Operator:=xlFilterValues

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    This may help:

    Sub test()    
        Dim obj As Object
        For Each obj In Sheet1.OLEObjects
            If TypeName(obj.Object) = "CheckBox" Then
                MsgBox obj.Name
            End If
        Next obj
        
    End Sub
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    VBAX Regular
    Joined
    Jun 2018
    Posts
    42
    Location
    Thanks mate, I mucked around with it for about a day and couldn't get what I needed. I ended up staying with form control checkboxes and changed the way I was running some subsequent things.

  4. #4
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,194
    Location
    Glad you got it sorted in the end.

    I try not to use these objects as I use excel 2007 & 2010, one of which will not allow me to use them due to a glitch and the other (work) has blocked ActiveX altogether for security.

    So I tend to stick to form based control's
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2403, Build 17425.20146

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •