Display number of non-empty comboboxes

Solved
tav2014 Posted messages 3 Status Member -  
Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   -
Hello everyone
Beginner in VBA, I created a UserForm composed of ComboBoxes numbered from 1 to 20
When filling out the userform I would like to display in a textbox the number of non-filled combo boxes but only for those numbered between 8 and 17.
Thanks in advance

3 answers

  1. Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 784
     
    Hello,

    All the basics here:

    https://silkyroad.developpez.com/VBA/ControlesUserForm/

    and here:

    https://silkyroad.developpez.com/VBA/UserForm/

    --

    Best regards,
    Patrice
    0
  2. tav2014 Posted messages 3 Status Member
     
    Thank you very much for this quick response; however, I haven't found a solution to my problem. I did find a way to count all the comboboxes in my userform, but I can't adapt this procedure to only count the combo from 8 to 17.

    Sub count_filled_Comboboxes(usf As Object)
    Dim Ctrl As Control
    Dim i As Byte

    For Each Ctrl In usf.Controls
    If TypeName(Ctrl) = "ComBox" Then
    If Ctrl.Value <> "" Then i = i + 1
    End If
    Next
    UserForm3.TextBox132 = i

    End Sub

    Thank you for your help
    0
  3. tav2014 Posted messages 3 Status Member
     
    In the end I managed to achieve my result as follows
    Dim Ctrl As Control
    Dim i As Byte

    For nb = 8 To 22
    If Me("Combobox" & nb).Value <> "" Then i = i + 1

    Next

    MsgBox ("i")

    End Sub
    thank you
    0