![]() |
cycle through comboboxs with an integer
Just wondering if this is possible. I know the code I have writen so far
doesn't work but any idea's would be great. sub mysub() dim i as integer dim e as string e = 1 for i = 1 to 75 ComboBox & i.value = sheets("list").range("D"& e) e = e + 1 next i end sub -- Thanks! Shane W |
cycle through comboboxs with an integer
Controls("Combobox" & i).value= ....... "whylite" wrote: Just wondering if this is possible. I know the code I have writen so far doesn't work but any idea's would be great. sub mysub() dim i as integer dim e as string e = 1 for i = 1 to 75 ComboBox & i.value = sheets("list").range("D"& e) e = e + 1 next i end sub -- Thanks! Shane W |
cycle through comboboxs with an integer
i think i know what you mean, but not certain 1st thought If you are just trying to add multiple values to a combobox use Code ------------------- sub mysub() dim i as integer dim e as string e = 1 for i = 1 to 75 ComboBox1.additem sheets("list").range("D"& e).value e = e + 1 next i end su ------------------- 2nd thought You are trying to loop though a number of different comboboxes Code ------------------- ' in the userform module Private Sub UserForm_Initialize() Dim obj As MSForms.Control, i As Long, c() As Class1 Range("a1").Select For Each obj In Me.Controls If TypeName(obj) = "ComboBox" Then ReDim Preserve c(i) Set c(i) = New Class1 c(i).SetComboBox obj obj.Tag = i End If Next obj End Sub 'create a class module and put this code in there Private WithEvents cb1 As MSForms.ComboBox Sub SetComboBox(ByVal cb As MSForms.ComboBox) Set cb1 = cb cb1.AddItem (ActiveCell.Value) ActiveCell.Offset(1, 0).Select End Su ------------------- this also gives you the option to use one change sub in the clas module for all the comboboxes g -- irishboy ----------------------------------------------------------------------- irishboyx's Profile: http://www.excelforum.com/member.php...fo&userid=3249 View this thread: http://www.excelforum.com/showthread.php?threadid=52303 |
All times are GMT +1. The time now is 08:02 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com