View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jeremy Jeremy is offline
external usenet poster
 
Posts: 184
Default Looping Macro with input boxes all related to one number

I have this macro designed (keep in mind I don't really understand it all),
it works really well but would like to make it so that I don't have to retype
the account number all the time. The number is referenced to 3 different
cells one ending with an "a" one with an "n" and one with a "g". So I have
to have the account = input box for each cell referenced. Here is what I
have done. TIA.

Sub Enter_Runners()
'
' Enter_Runners Macro
' Macro recorded 10/17/2005 by Jeremy Barth
'
' Keyboard Shortcut: Ctrl+e

Const TXTTITLE As String = "Turkey Trot Participants"
Const NUMBERMSG As String = "Please enter Runner's Number"
Const NAMEMSG As String = "Please enter Runner's Name"
Const AGEMSG As String = "Please enter Runner's Age"
Const GENDERMSG As String = "Please enter (1) for Male or (2) for Female"
Dim ACCOUNT As Variant
Dim NUMBER As Variant

Do

ACCOUNT = InputBox(NUMBERMSG, TXTTITLE)
If ACCOUNT = "" Then Exit Sub
ACCOUNT = "_" & ACCOUNT & "n"
If ACCOUNT = "_." Then
Application.Goto Reference:="MENU"
Exit Sub
Else

With Range(ACCOUNT)
Application.Goto Reference:=.Cells
NUMBER = InputBox(NAMEMSG, TXTTITLE)
If NUMBER = "" Then Exit Sub
If .HasFormula Then
.Formula = NUMBER
Else
.Formula = NUMBER
End If
End With
End If
ACCOUNT = InputBox(NUMBERMSG, TXTTITLE)
If ACCOUNT = "" Then Exit Sub
ACCOUNT = "_" & ACCOUNT & "a"
If ACCOUNT = "_." Then
Application.Goto Reference:="MENU"
Exit Sub
Else
With Range(ACCOUNT)
Application.Goto Reference:=.Cells
NUMBER = InputBox(AGEMSG, TXTTITLE)
If NUMBER = "" Then Exit Sub
If .HasFormula Then
.Formula = NUMBER
Else
.Formula = NUMBER
End If
End With

End If
ACCOUNT = InputBox(NUMBERMSG, TXTTITLE)
If ACCOUNT = "" Then Exit Sub
ACCOUNT = "_" & ACCOUNT & "g"
If ACCOUNT = "_." Then
Application.Goto Reference:="MENU"
Exit Sub
Else
With Range(ACCOUNT)
Application.Goto Reference:=.Cells
NUMBER = InputBox(GENDERMSG, TXTTITLE)
If NUMBER = "" Then Exit Sub
If .HasFormula Then
.Formula = NUMBER
Else
.Formula = NUMBER
End If
End With

End If
Loop
End Sub