Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Required Cell Input Loop

Status
Not open for further replies.

olympus

Technical User
Apr 16, 2002
26
US
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
 
Hi
This may be possible but I'd suggest that an easier way would be to create a userform with 3 textboxes. These can then be evaluated and their values entered into your worksheet whenever a user clicks "OK".

;-)
If a man says something and there are no women there to hear him, is he still wrong? [ponder]
How do I get the best answers?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top