I'm trying to require that the user imput a value into cells B3, B4, and B5. I have the following code to run "on open". The problem is this code allows the user to click on OK in each dialogue box then continue without entering any data into cells B3,B4, or B5. How can I require that data be entered into these cells? I'd like the same dialogue boxes to pop up until data is entered into the required cell. The code I have so far is below. Many thanks.
John
Private Sub Workbook_Open()
Application.DisplayFormulaBar = False
Dim optBut As OptionButton
For Each optBut In ActiveSheet.OptionButtons
optBut.Value = False
Next
Range("b3").Select
If Range("b3") = "" Then
MsgBox "You must enter a weight"
Range("b3").Select
Else
'Exit Sub
End If
Range("b4").Select
If Range("b4") = "" Then
MsgBox "You must enter a serum creatinine"
Range("b4").Select
Else
'Exit Sub
End If
Range("b5").Select
If Range("b5") = "" Then
MsgBox "You must enter the patient's age"
Range("b5").Select
Else
'Exit Sub
End If
Range("e3").Select
If Range("j2") = "0" Then
MsgBox "You must select gender"
Range("e3").Select
Else
'Exit Sub
End If
If Not (IsEmpty(Range("B3"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B4"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B5"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("j2"))) Then
Else
Exit Sub
End If
End Sub
John
Private Sub Workbook_Open()
Application.DisplayFormulaBar = False
Dim optBut As OptionButton
For Each optBut In ActiveSheet.OptionButtons
optBut.Value = False
Next
Range("b3").Select
If Range("b3") = "" Then
MsgBox "You must enter a weight"
Range("b3").Select
Else
'Exit Sub
End If
Range("b4").Select
If Range("b4") = "" Then
MsgBox "You must enter a serum creatinine"
Range("b4").Select
Else
'Exit Sub
End If
Range("b5").Select
If Range("b5") = "" Then
MsgBox "You must enter the patient's age"
Range("b5").Select
Else
'Exit Sub
End If
Range("e3").Select
If Range("j2") = "0" Then
MsgBox "You must select gender"
Range("e3").Select
Else
'Exit Sub
End If
If Not (IsEmpty(Range("B3"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B4"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("B5"))) Then
Else
Exit Sub
End If
If Not (IsEmpty(Range("j2"))) Then
Else
Exit Sub
End If
End Sub