View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Andrew Taylor Andrew Taylor is offline
external usenet poster
 
Posts: 225
Default Looping through Labels

Try:
Controls("lblMachine" & i).Caption = cbxMachine.Value

Also, you never seem to increment i in your loop, so it will run
for ever (unless you've omitted some lines). I'd prefer a For loop
for this:

For i = 1 to 6
Controls("lblMachine" & i).Caption = cbxMachine.Value
Next


gti_jobert wrote:
Hi all,

I have 6 labels named lblMachine1, lblMachine2, lblMachine3,
lblMachine4, lblMachine5, and lblMachine6.

Is there a way to loop through all of these labels and populate all of
them with data? I have tried the following;


Code:
--------------------


Dim i%

i = 1
Do
lblMachine(i).Caption = cbxMachine.Value
Loop Until i = 6


--------------------


Please help. Thanks all.


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=503266