Option Explicit
Private Sub SubmitButton_Click()
If ComboBox1.Value = "" Then
MsgBox "Please Select a Subject", vbCritical
Exit Sub
End If
If ComboBox2.Value = "" Then
MsgBox "Please Select a Year", vbCritical
Exit Sub
End If
If TextBox1.Value = "" Then
MsgBox "Please Enter the some Numeric value", vbCritical
Exit Sub
End If
With ThisWorkbook.Worksheets("Sheet1")
Dim nextRow As Long
nextRow = .Range("A" & .Rows.Count).End(xlUp).Row + 1
MsgBox nextRow
Dim nextCol As Long
nextCol = .Cells(1, .Columns.Count).End(xlToLeft).Column + 1
MsgBox nextCol
.Cells(nextRow, 1).Value = ComboBox1.Value
.Cells(nextRow + 1, 1).Value = TextBox1.Value
.Cells(1, nextCol).Value = ComboBox2.Value
End With
End Sub
Private Sub UserForm_Initialize()
ComboBox1.List = Array("English", "French", "Italian", "Spanish", "German")
ComboBox2.List = Array("2024", "2025", "2026", "2027", "1979")
ComboBox1.SetFocus
End Sub