Marks Score card with Userform
Private Sub CommandButton1_Click()
If Me.TextBox1.Value = "" Then
MsgBox "Please enter the name"
Exit Sub
Me.TextBox1.SetFocus
End If
Dim i As Integer
For i = 2 To 5
If Me.Controls("Textbox" & i).Value = "" Then
MsgBox "Please fill the box"
Exit Sub
Me.TextBox1.SetFocus
ElseIf Not IsNumeric(Controls("Textbox" & i).Value) Then
MsgBox "Please enter NUMERIC"
Exit Sub
Me.TextBox1.SetFocus
ElseIf Me.Controls("textbox" & i).Value > 100 Then
MsgBox "Marks should be <=100"
Exit Sub
Me.TextBox1.SetFocus
End If
Total = Total + Val(Controls("Textbox" & i).Value)
Next
TextBox6.Value = Total
R = Range("A" & Rows.Count).End(xlUp).Row + 1
Range("A" & R) = Me.TextBox1.Value
Range("B" & R) = Me.TextBox2.Value
Range("C" & R) = Me.TextBox3.Value
Range("D" & R) = Me.TextBox4.Value
Range("E" & R) = Me.TextBox5.Value
Range("F" & R) = Me.TextBox6.Value
Call Font_Adjustments
End Sub