Hello,
I am brand new (Day 1) to VBA programming and I am running into an issue when trying to activate a sheet based on the value chosen in my userForm that I cannot seem to solve. The error seems to be a compile error and says I am missing and End statement to one of my If Then statements, specifically:
Compile error:
End If without block If
I thought if the If Then statement was all on one line that I would not need an End If statement. In fact, if I try to add an End If statement, I get an error (all proceeding text turns red).
This is the part of the code with the End If error. Not sure what I am missing here.
Private Sub AddDataButton_Click()
Dim emptyRow As Long
'Activate sheet based on training type chosen
If MonthlySWATrainingButton.Value = True Then Monthly_SWA_Data.Activate
If MonthlyHSWATrainingButton.Value = True Then Monthly_HSWA_Data.Activate
If POSTTrainingButton.Value = True Then POST_Data.Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information (for Monthly SWA Training)
If MonthlySWATrainingButton.Value = True Then Cells(emptyRow, 1).Value = DurationTextBox.Value
Cells(emptyRow, 2).Value = NameComboBox.Value
Cells(emptyRow, 3).Value = DatePicker.Value
End If
'Transfer information (for POST Training)
If MonthlyPOSTTrainingButton.Value = True Then
Cells(emptyRow, 1).Value = CourseNameComboBox.Value
Cells(emptyRow, 2).Value = DurationTextBox.Value
Cells(emptyRow, 3).Value = NameComboBox.Value
Cells(emptyRow, 4).Value = DatePicker.Value
End If
'Transfer information (for Monthly HSWA Training)
If MonthlyHSWATrainingButton.Value = True Then
Cells(emptyRow, 1).Value = DurationTextBox.Value
Cells(emptyRow, 2).Value = NameComboBox.Value
Cells(emptyRow, 3).Value = DatePicker.Value
End If
End Sub
Thanks for the help!
Michelle
Bookmarks