G
Guest
I have this looping macro set up and would like to get it to go to different
cells on the same row. I'm trying to get it so that I can enter a number for
an individual and then have multiple input boxes pop up to ask different
questions and put those answers to those questions in different cells on the
same row but different column. All with only entering the persons number
once. Here is what I got.
The AGE = "_" & ACCOUNT & "a" is where I thought I could reference a
differnet range but it doesn't work
' Macro recorded 10/17/2005 by Jeremy Barth
'
' Keyboard Shortcut: Ctrl+e
Const TXTTITLE As String = "Turkey Trot Participants"
Const NUMBERMSG As String = "Enter Runner's Number"
Const NAMEMSG As String = "Enter Runner's Name"
Const AGEMSG As String = "Enter Runner's Age"
Const GENDERMSG As String = "Enter (1) for Male or (2) for Female"
Dim ACCOUNT As Variant
Dim Name As Variant
Dim AGE As Variant
Dim GENDER As Variant
Do
ACCOUNT = InputBox(NUMBERMSG, TXTTITLE)
If ACCOUNT = "" Then Exit Sub
ACCOUNT = "_" & ACCOUNT & "n"
AGE = "_" & ACCOUNT & "a"
If ACCOUNT = "_." Then
Application.Goto Reference:="MENU"
Exit Sub
Else
With Range(ACCOUNT)
Application.Goto Reference:=.Cells
Name = InputBox(NAMEMSG, TXTTITLE)
If Name = "" Then Exit Sub
If .HasFormula Then
.Formula = Name
Else
.Formula = Name
End If
End With
AGE = "_" & ACCOUNT & "a"
With Range(ACCOUNT)
ActiveCell.Offset(0, -2).Select
AGE = InputBox(AGEMSG, TXTTITLE)
If AGE = "" Then Exit Sub
If .HasFormula Then
.Formula = AGE
Else
.Formula = AGE
End If
End With
With Range(ACCOUNT)
ActiveCell.Offset(0, -1).Select
GENDER = InputBox(GENDERMSG, TXTTITLE)
If GENDER = "" Then Exit Sub
If .HasFormula Then
.Formula = GENDER
Else
.Formula = GENDER
End If
End With
End If
Loop
End Sub
TIA
cells on the same row. I'm trying to get it so that I can enter a number for
an individual and then have multiple input boxes pop up to ask different
questions and put those answers to those questions in different cells on the
same row but different column. All with only entering the persons number
once. Here is what I got.
The AGE = "_" & ACCOUNT & "a" is where I thought I could reference a
differnet range but it doesn't work
' Macro recorded 10/17/2005 by Jeremy Barth
'
' Keyboard Shortcut: Ctrl+e
Const TXTTITLE As String = "Turkey Trot Participants"
Const NUMBERMSG As String = "Enter Runner's Number"
Const NAMEMSG As String = "Enter Runner's Name"
Const AGEMSG As String = "Enter Runner's Age"
Const GENDERMSG As String = "Enter (1) for Male or (2) for Female"
Dim ACCOUNT As Variant
Dim Name As Variant
Dim AGE As Variant
Dim GENDER As Variant
Do
ACCOUNT = InputBox(NUMBERMSG, TXTTITLE)
If ACCOUNT = "" Then Exit Sub
ACCOUNT = "_" & ACCOUNT & "n"
AGE = "_" & ACCOUNT & "a"
If ACCOUNT = "_." Then
Application.Goto Reference:="MENU"
Exit Sub
Else
With Range(ACCOUNT)
Application.Goto Reference:=.Cells
Name = InputBox(NAMEMSG, TXTTITLE)
If Name = "" Then Exit Sub
If .HasFormula Then
.Formula = Name
Else
.Formula = Name
End If
End With
AGE = "_" & ACCOUNT & "a"
With Range(ACCOUNT)
ActiveCell.Offset(0, -2).Select
AGE = InputBox(AGEMSG, TXTTITLE)
If AGE = "" Then Exit Sub
If .HasFormula Then
.Formula = AGE
Else
.Formula = AGE
End If
End With
With Range(ACCOUNT)
ActiveCell.Offset(0, -1).Select
GENDER = InputBox(GENDERMSG, TXTTITLE)
If GENDER = "" Then Exit Sub
If .HasFormula Then
.Formula = GENDER
Else
.Formula = GENDER
End If
End With
End If
Loop
End Sub
TIA