PDA

View Full Version : loop help



liam1289
08-18-2010, 11:32 AM
Im trying to do a loop where a msg box ask the user for name,address and age. after the user inserts info i want it 2 appear on the spreadsheet.also if the user is under 18 i dont want there age to be shown on spreadsheet..

code is

Private Sub cmdpatient_Click()

Dim age As Integer
Dim address As String
Dim name_of_patient As String


For counter = 0 To 1

name_of_patient = InputBox("Enter name of Patient")
Cells(counter, 20).Value = name_of_patient
address = InputBox("Enter Address Of Patient")
Cells(counter, 21).Value = address
age = InputBox("Enter Age of Patient")
Cells(counter, 22).Value = age

Bob Phillips
08-18-2010, 01:36 PM
Private Sub cmdpatient_Click()

Dim age As Integer
Dim address As String
Dim name_of_patient As String


For counter = 0 To 1

name_of_patient = InputBox("Enter name of Patient")
Cells(counter, 20).Value = name_of_patient
address = InputBox("Enter Address Of Patient")
Cells(counter, 21).Value = address
age = InputBox("Enter Age of Patient")
if age > 18 then Cells(counter, 22).Value = age