teebird
Technical User
- Dec 11, 2001
- 239
I have this code in an Add function but it is not working the way I want.
If Len(Range("B5").Value) = 0 Then
MsgBox "Please add the Patient's HRN!", vbOKOnly, "HRN Error"
Range("B5").Select
Range("B5").ClearContents
Exit Sub
Else: ws.Cells(orow, "A").Value = Range("Input!B5")
End If
If Len(Range("B6").Value) = 0 Then
MsgBox "Please add the Patient's Name!", vbOKOnly, "Name Error"
Range("B6").Select
Range("B6").ClearContents
Exit Sub
Else: ws.Cells(orow, "B").Value = Range("Input!B6")
End If
If Len(Range("B7").Value) = 0 Then
MsgBox "Please add the Patient's Date of Birth!", vbOKOnly, "DOB Error"
Range("B7").Select
Range("B7").ClearContents
Exit Sub
Else: ws.Cells(orow, "C").Value = Range("Input!B7")
End If
Each time I click the OK button on the messagebox to close the dialog box, the previous value is entered, and the next value is put in the next cell (next column).
So in my spreadshhet I end up with
Column 1 - Column 2 - Column 3
120 -
120 - Charlie Brown -
120 - Charlie Brown - 15/04/1996 -
When I really want 120 Charlie Brown 15/04/1996
Any help woiuld be great...
Tee
If Len(Range("B5").Value) = 0 Then
MsgBox "Please add the Patient's HRN!", vbOKOnly, "HRN Error"
Range("B5").Select
Range("B5").ClearContents
Exit Sub
Else: ws.Cells(orow, "A").Value = Range("Input!B5")
End If
If Len(Range("B6").Value) = 0 Then
MsgBox "Please add the Patient's Name!", vbOKOnly, "Name Error"
Range("B6").Select
Range("B6").ClearContents
Exit Sub
Else: ws.Cells(orow, "B").Value = Range("Input!B6")
End If
If Len(Range("B7").Value) = 0 Then
MsgBox "Please add the Patient's Date of Birth!", vbOKOnly, "DOB Error"
Range("B7").Select
Range("B7").ClearContents
Exit Sub
Else: ws.Cells(orow, "C").Value = Range("Input!B7")
End If
Each time I click the OK button on the messagebox to close the dialog box, the previous value is entered, and the next value is put in the next cell (next column).
So in my spreadshhet I end up with
Column 1 - Column 2 - Column 3
120 -
120 - Charlie Brown -
120 - Charlie Brown - 15/04/1996 -
When I really want 120 Charlie Brown 15/04/1996
Any help woiuld be great...
Tee