Hello,
I'm pretty new at programming with VBA.
I'v got an excel document with a sheet "errorabortlijst" and a second sheet "kassasystemmenu".
Now i want to make one userform with a combobox that let me select from all the errorabort codes from the excel sheet "errorabortlijst" and 1 textboxe that show me the description of that error abort and the second textbox that show me the solution belonging to the selected errorabort code.
So far i got this working.
My problem comes with the second combobox. I also manage to get able to let me select a kassa from all the kassatypes (the are in the second worksheet called kassasysteemmenu) but the textbox that belongs to this combobox and is rigth below this combobox doesn't fill up when i select a kassatype.
This is what i have programmed so far:
Private Sub UserForm_Initialize()
lr = Sheets("Errorabortlijst").Cells(Sheets("Errorabortlijst").Rows.Count, 1).End(xlUp).Row
Set Range2 = Sheets("Errorabortlijst").Range("A2:A" & lr)
For Each cel In Range2
With UserForm.Cmbxerrorabort
.AddItem Worksheets("Errorabortlijst").Range("A" & cel.Row)
End With
Next
lr = Sheets("Kassasysteemmenu").Cells(Sheets("Kassasysteemmenu").Rows.Count, 1).End(xlUp).Row
Set Range3 = Sheets("Kassasysteemmenu").Range("A2:A" & lr)
For Each cel In Range3
With UserForm.Cmbxkassa
.AddItem Worksheets("Kassasysteemmenu").Range("A" & cel.Row)
End With
Next
End Sub
Private Sub Cmbxerrorabort_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Errorabortlijst")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Val(Me.Cmbxerrorabort.Value) = ws.Cells(i, "A") Then
Me.Txtbxfoutomschrijving = ws.Cells(i, "B").Value
Me.Txtbxoplossing = ws.Cells(i, "C").Value
End If
Next i
End Sub
Private Sub Cmbxkassa_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Kassasysteemmenu")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Val(Me.Cmbxkassa.Value) = ws.Cells(i, "A") Then
Me.Txtbxkassa = ws.Cells(i, "B").Value
End If
Next i
End Sub
Can someone explane to me what i'm doing wrong heren?
I'm pretty new at programming with VBA.
I'v got an excel document with a sheet "errorabortlijst" and a second sheet "kassasystemmenu".
Now i want to make one userform with a combobox that let me select from all the errorabort codes from the excel sheet "errorabortlijst" and 1 textboxe that show me the description of that error abort and the second textbox that show me the solution belonging to the selected errorabort code.
So far i got this working.
My problem comes with the second combobox. I also manage to get able to let me select a kassa from all the kassatypes (the are in the second worksheet called kassasysteemmenu) but the textbox that belongs to this combobox and is rigth below this combobox doesn't fill up when i select a kassatype.
This is what i have programmed so far:
Private Sub UserForm_Initialize()
lr = Sheets("Errorabortlijst").Cells(Sheets("Errorabortlijst").Rows.Count, 1).End(xlUp).Row
Set Range2 = Sheets("Errorabortlijst").Range("A2:A" & lr)
For Each cel In Range2
With UserForm.Cmbxerrorabort
.AddItem Worksheets("Errorabortlijst").Range("A" & cel.Row)
End With
Next
lr = Sheets("Kassasysteemmenu").Cells(Sheets("Kassasysteemmenu").Rows.Count, 1).End(xlUp).Row
Set Range3 = Sheets("Kassasysteemmenu").Range("A2:A" & lr)
For Each cel In Range3
With UserForm.Cmbxkassa
.AddItem Worksheets("Kassasysteemmenu").Range("A" & cel.Row)
End With
Next
End Sub
Private Sub Cmbxerrorabort_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Errorabortlijst")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Val(Me.Cmbxerrorabort.Value) = ws.Cells(i, "A") Then
Me.Txtbxfoutomschrijving = ws.Cells(i, "B").Value
Me.Txtbxoplossing = ws.Cells(i, "C").Value
End If
Next i
End Sub
Private Sub Cmbxkassa_Change()
Dim i As Long, LastRow As Long, ws As Worksheet
Set ws = Sheets("Kassasysteemmenu")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow
If Val(Me.Cmbxkassa.Value) = ws.Cells(i, "A") Then
Me.Txtbxkassa = ws.Cells(i, "B").Value
End If
Next i
End Sub
Can someone explane to me what i'm doing wrong heren?