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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select data based on numerical entry, Excel 2000 VBA

Status
Not open for further replies.

vamoose

Programmer
Joined
Oct 16, 2005
Messages
320
Location
MX
Hi, I am using MSExcel 2000 VBA. What I am trying to do is something like this:
1. Use a inputbox to enter a number between 1 and 5
2. Based on the numerical entry, select the appropriate text data from the list and assign it to the txt variable.
Rough example:

dim txt as string
txt=inputbox("Enter a number between 1 & 5")
on txt = "one","two","three","four","five"

I can't remember how to do this or what it is called so I can search for it.
Thanks
 
Hi Vamoose,

You could use something like:
Code:
Sub ArrayTest()
Dim MyArray(5)
MyArray(1) = "One"
MyArray(2) = "Two"
MyArray(3) = "Three"
MyArray(4) = "Four"
MyArray(5) = "Five"
MsgBox MyArray(InputBox(Value))
End Sub

Cheers
PS: The above code has no error checking
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top