Gruppe
Dialog
Problem
Bei Eingabe einer Zahl in Spalte A ab A3 soll eine UserForm-ComboBox mit den Artikeln erscheinen, deren Nummer im Blatt Material mit dieser Zahl beginnt.
ClassModule: Tabelle1
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 Then Exit Sub
If Target.Row < 3 Then Exit Sub
If IsEmpty(Target) Then Exit Sub
Application.EnableEvents = False
On Error GoTo ERRORHANDLER
frmSelect.Show
ERRORHANDLER:
Application.EnableEvents = True
End Sub
ClassModule: frmSelect
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
Dim iRow As Integer
With Worksheets("Material")
iRow = WorksheetFunction.Match(CInt(cboSelect.Value), .Columns(1), 0)
ActiveCell.Value = .Cells(iRow, 1).Value
ActiveCell.Offset(0, 1).Value = .Cells(iRow, 2).Value
ActiveCell.Offset(0, 2).Value = .Cells(iRow, 3).Value
End With
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim iRow As Integer
iRow = 4
With Worksheets("Material")
Do Until IsEmpty(.Cells(iRow, 1))
If Left(.Cells(iRow, 1).Value, 1) = CStr(ActiveCell.Value) Then
cboSelect.AddItem .Cells(iRow, 1).Value
End If
iRow = iRow + 1
Loop
End With
If cboSelect.ListCount > 0 Then
cboSelect.ListIndex = 0
Else
Unload Me
End If
End Sub