Single Select Listbox and multiselect Listbox in Userform

silentwolf

Well-known Member
Joined
May 14, 2008
Messages
1,216
Office Version
  1. 2016
Hi guys I am stuck again...

I got a single select Listbox and a multiselect listbox in a userform.. and other controls like txtboxes and comboxes..

following code I have to prevent the user to

Code:
   Sub Test 
    Dim ctl As MSForms.Control
    Dim lItem As Long
    
'Validate whether all boxes are completed

For Each ctl In frmEintrag.EintragPages(EintragPages.Value).Controls
    If (TypeName(ctl) = "TextBox") Or (TypeName(ctl) = "ComboBox") Or (TypeName(ctl) = "Listbox") Then
        If ctl.Value = "" Then
            MsgBox ("Nicht alle Informationen sind gegeben. Bitte eintragen!"), vbCritical + vbOKOnly, p_cstrAppMeldung
            Exit Sub
        End If
    End If
Next ctl
End sub

Also I found a similar thread here wich works when there is on multiselect listbox in the form
Code:
Private Sub lstObjekte_Click()
    Dim booSelected As Boolean
    Dim intCounter As Integer
    
    With lstMitarbeiter
        For intCounter = 0 To .ListCount - 1
            booSelected = booSelected And .Selected(intCounter)
        Next intCounter
    End With
  
    If Not booSelected Then
        MsgBox "No selection in Listbox"
    End If
End Sub

In the userform I have the btnOk property set to false

Now how I would need to change this so the btnOk is enabled = false until all controls including multiselect control and single select control are selected.

Hope someone could help me with this.

Many thanks

Albert
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Forum statistics

Threads
1,221,787
Messages
6,161,960
Members
451,734
Latest member
Anmol Pandey19

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top