Gruppe
Dialog
Problem
n einer UserForm soll eine OK-Schaltfläche erst aktiviert werden, wenn in einer ListBox das 3. Element ausgewählt wird.
ClassModule: frmThree
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim iCounter As Integer, iCount As Integer
For iCounter = 0 To lstValues.ListCount - 1
If lstValues.Selected(iCounter) Then
iCount = iCount + 1
Cells(iCount, 2).Value = lstValues.List(iCounter)
End If
Next iCounter
Unload Me
End Sub
Private Sub lstValues_Change()
Dim iCounter As Integer, iCount As Integer
For iCounter = 0 To lstValues.ListCount - 1
If lstValues.Selected(iCounter) Then
iCount = iCount + 1
End If
Next iCounter
If iCount = 3 Then
cmdOK.Enabled = True
Else
cmdOK.Enabled = False
End If
End Sub
Private Sub UserForm_Initialize()
lstValues.List = Range("A1").CurrentRegion.Value
End Sub
StandardModule: basMain
Sub CallForm()
frmThree.Show
End Sub