Gruppe
Dialog
Problem
In eine UserForm-ComboBox sollen die Werte aus Spalte 2 ohne Leerzellen und ohne Doppel aufgerufen werden
ClassModule: frmValues
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim wks As Worksheet
Dim vRow As Variant
Dim iRow As Integer, iRowT As Integer, iRowL As Integer
Application.ScreenUpdating = False
Set wks = ActiveSheet
iRowL = Cells(Rows.Count, 2).End(xlUp).Row
Workbooks.Add
For iRow = 3 To iRowL
vRow = Application.Match(wks.Cells(iRow, 2).Value, Columns(1), 0)
If IsError(vRow) Then
iRowT = iRowT + 1
Cells(iRowT, 1).Value = wks.Cells(iRow, 2).Value
End If
Next iRow
Range("A1").CurrentRegion.Sort _
key1:=Range("A1"), order1:=xlAscending, header:=xlNo
With cboValues
.List = Range("A1").CurrentRegion.Value
If .ListCount > 0 Then .ListIndex = 0
End With
ActiveWorkbook.Close savechanges:=False
Application.ScreenUpdating = True
End Sub
StandardModule: Modul1
Sub CallForm()
frmValues.Show
End Sub