Hi all,
Used to tinker in a very amateur way with VBA many years ago and have discovered its not like riding a bike, some years on and I cant remember a thing.
I'm trying to put a sheet together that shows staff course qualifications and completion dates, the "course name" headers are in row 4 and the staff names are in column B.
I have a simple form that users can use to update their completion dates, this form comprises of 2 combo box's, the first (ComboBox1) lists staff names and the second (ComboBox2) lists course qualifications. Also on the form is a textbox (TextBox1) for the user to input a date of course completion, finally a submit button.
The theory behind the form is that when the user hits submit (CommandButton1), column B is searched for the users name selected in ComboBox1 and row 4 is searched for the course title from ComboBox2, then the completion date from TextBox1 is inputted in the relevant cell on the sheet ("MOK i-Learns")
This is the code that I have come up with but am getting a "Compile Error: For without Next"
Any help would be greatly appreciated. Thanks
Used to tinker in a very amateur way with VBA many years ago and have discovered its not like riding a bike, some years on and I cant remember a thing.
I'm trying to put a sheet together that shows staff course qualifications and completion dates, the "course name" headers are in row 4 and the staff names are in column B.
I have a simple form that users can use to update their completion dates, this form comprises of 2 combo box's, the first (ComboBox1) lists staff names and the second (ComboBox2) lists course qualifications. Also on the form is a textbox (TextBox1) for the user to input a date of course completion, finally a submit button.
The theory behind the form is that when the user hits submit (CommandButton1), column B is searched for the users name selected in ComboBox1 and row 4 is searched for the course title from ComboBox2, then the completion date from TextBox1 is inputted in the relevant cell on the sheet ("MOK i-Learns")
This is the code that I have come up with but am getting a "Compile Error: For without Next"
Any help would be greatly appreciated. Thanks
VBA Code:
Private Sub CommandButton1_Click()
Dim elearn_name As String
Dim crew_name As String
Dim i As Integer
Dim j As Integer
Dim lastRow As Long
Dim lastCol As Long
elearn_name = ComboBox2
crew_name = ComboBox1
lastRow = Worksheets("MOK i-Learns").Cells(Rows.Count, 1).End(xlUp).Row
lastCol = Worksheets("MOK i-Learns").Cells(Columns.Count, 1).End(xlLeft).Column
For i = 4 To lastRow
For j = 2 To lastCol
If Worksheets("MOK i-Learns").Cells(i, 2).Value = crew_name And Worksheets("MOK i-Learns").Cells(4, j).Value = elearn_name Then
Worksheets("MOK i-Learns").Cells(i, j).Value = TextBox1.Text
End If
Next
End Sub