Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
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
How do I add an integer to an existing integer? Aaron Excel Worksheet Functions 3 December 17th 09 09:46 PM
How do I make a graph with 2-cycle X 3-cycle log-log graph paper? Charles A. Wilson Charts and Charting in Excel 1 December 17th 09 03:03 AM
How do I keep result from 1 iteration cycle to use in next cycle? sgl8akm Excel Discussion (Misc queries) 0 July 27th 06 08:28 PM
2 comboboxs, different sheet references Kryer Excel Programming 2 September 21st 05 10:58 PM
How do I create a button to reset ComboBoxs noirnor Excel Programming 5 September 10th 03 01:55 AM


All times are GMT +1. The time now is 08:09 AM.

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"