LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Need Help Creating a Loop

Do you mean that the cell to check needs to change for each listbox?

B5, then B6, then B7, ..., B76???

If yes:

Option Explicit
Sub testme()

Dim OLEObj As OLEObject
Dim iCtr As Long
Dim CellToCheck As Range

Set CellToCheck = Sheet1.Range("b5")

For iCtr = 1 To 72
Set OLEObj = Sheet1.OLEObjects("Listbox" & iCtr)
With OLEObj.Object
.Clear
.AddItem "Select From List"
.AddItem "1 (High Risk)"
.AddItem "2"
.AddItem "3"
.AddItem "4"
.AddItem "5 (Low Risk)"

Select Case LCase(CellToCheck.Value)
Case Is = LCase("Select from List")
.ListIndex = 0
Case Is = LCase("1 (High Risk)")
.ListIndex = 1
Case Is = "2", "3", "4"
.ListIndex = CellToCheck.Value
Case Is = LCase("5 (Low Risk)")
.ListIndex = 5
End Select
End With
'dropdown one row for the next listbox
Set CellToCheck = CellToCheck.Offset(1, 0)
Next iCtr
End Sub


wrote:

Dave:

Thanks. Good question: No, I need the listindex to increment as well;
starting with B5. I guess that will change the code ...

Regards,

Jeff


--

Dave Peterson
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a loop JakeShipley2008 Excel Discussion (Misc queries) 2 September 9th 08 02:17 PM
Creating a loop JakeShipley2008 Excel Discussion (Misc queries) 1 September 8th 08 10:26 PM
Creating a loop shart Excel Programming 10 December 21st 05 08:24 AM
Creating a loop Ibuprofen Excel Programming 1 October 26th 05 04:41 AM
Creating a For Loop Justin Ragsdale Excel Programming 5 May 23rd 04 10:40 PM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"