Gruppe
Dialog
Bereich
ComboBox
Thema
Nur Zellen mit Inhalt in ComboBox listen
Problem
Wie kann ich aus einer Tabellenspalte nur die Zellen in eine UserForm übernehmen, die nicht leer sind?
Lösung
Geben Sie den nachfolgenden Code in das Klassenmodul der UserForm ein.
ClassModule: Tabelle12
Private Sub CommandButton1_Click()
UserForm1.Show
End Sub
ClassModule: frmNoEmptys
Private Sub cmdContinue_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim iRow As Integer, iRowL As Integer
iRowL = Cells(Rows.Count, 1).End(xlUp).Row
For iRow = 1 To iRowL
If Not IsEmpty(Cells(iRow, 1)) Then
cbonoemptys.AddItem Cells(iRow, 1).Value
End If
Next iRow
End Sub
StandardModule: basMain
Sub CallForm()
frmNoEmptys.Show
End Sub