View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] jcrump64@yahoo.com is offline
external usenet poster
 
Posts: 3
Default Need Help Creating a Loop

I am trying to avoid having to enter the following code 72 times (once
for each fo the 72 listboxes I have) in the worksheet:

Sheet1.ListBox1.AddItem "Select From List"
Sheet1.ListBox1.AddItem "1 (High Risk)"
Sheet1.ListBox1.AddItem "2"
Sheet1.ListBox1.AddItem "3"
Sheet1.ListBox1.AddItem "4"
Sheet1.ListBox1.AddItem "5 (Low Risk)"
If Sheet1.Range("B5") = "Select From List" Then
Sheet1.ListBox1.ListIndex = 0
End If
If Sheet1.Range("B5") = "1 (High Risk)" Then
Sheet1.ListBox1.ListIndex = 1
End If
If Sheet1.Range("B5") = "2" Then
Sheet1.ListBox1.ListIndex = 2
End If
If Sheet1.Range("B5") = "3" Then
Sheet1.ListBox1.ListIndex = 3
End If
If Sheet1.Range("B5") = "4" Then
Sheet1.ListBox1.ListIndex = 4
End If
If Sheet1.Range("B5") = "5 (Low Risk)" Then
Sheet1.ListBox1.ListIndex = 5
End If

Any help?

Thanks,

Jeff