Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Table from labels

If you dim an array as labels you ned to refer to it as labels, not label (an array is not like a collection)

Dim labels(5)
labels(0) = Label1.Caption
labesl(1) = Label2.Caption

--

John Green - Excel MVP
Sydney
Australia


"T.K Kullervo" wrote in message ...
I want to refer to many labels inside a for loop. Is it possible to make a
table from the labels like labels(5)? I tried
Dim labels(5) as label
label(0) = Label1.. And so on

How is it done right?




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Table from labels

Yes, but i want to control my labels in a for-loop
Like this
For i = 0 To 5
Labels(i).Text = "This text is in every label after the loop"
Next i
How can i do this?

"John Green" wrote in message
...
If you dim an array as labels you ned to refer to it as labels, not label

(an array is not like a collection)

Dim labels(5)
labels(0) = Label1.Caption
labesl(1) = Label2.Caption

--

John Green - Excel MVP
Sydney
Australia


"T.K Kullervo" wrote in message

...
I want to refer to many labels inside a for loop. Is it possible to make

a
table from the labels like labels(5)? I tried
Dim labels(5) as label
label(0) = Label1.. And so on

How is it done right?






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Table from labels

If you are talking about Label objects created in a worksheet using the Forms toolbar, you can loop through the collection as
follows:

Sub Test()
Dim i As Integer
For i = 1 To 5
ActiveSheet.Labels(i).Caption = "This text is in every label after the loop"
Next i
End Sub

If you are talking about label controls in a userform that you have given names "Label1", "Label2", etc.

Private Sub UserForm_Click()
Dim i As Integer
For i = 1 To 5
Me.Controls("Label" & i).Caption = "This text is in every label after the loop"
Next i
End Sub


--

John Green - Excel MVP
Sydney
Australia


"T.K Kullervo" wrote in message ...
Yes, but i want to control my labels in a for-loop
Like this
For i = 0 To 5
Labels(i).Text = "This text is in every label after the loop"
Next i
How can i do this?

"John Green" wrote in message
...
If you dim an array as labels you ned to refer to it as labels, not label

(an array is not like a collection)

Dim labels(5)
labels(0) = Label1.Caption
labesl(1) = Label2.Caption

--

John Green - Excel MVP
Sydney
Australia


"T.K Kullervo" wrote in message

...
I want to refer to many labels inside a for loop. Is it possible to make

a
table from the labels like labels(5)? I tried
Dim labels(5) as label
label(0) = Label1.. And so on

How is it done right?








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 find a value in a table without using the labels? BobbyR Excel Worksheet Functions 1 March 18th 10 08:50 AM
How do I get labels to repeat in a pivot table? snmcpa Excel Worksheet Functions 3 September 29th 06 05:54 AM
PIvot Table - Repeat Row Labels JenL Excel Discussion (Misc queries) 1 February 10th 06 05:04 PM
How do I get the Pivot Table row labels to repeat? karen_g Excel Discussion (Misc queries) 2 February 7th 06 09:36 PM
How do I repeat labels in a Pivot Table teddy Excel Discussion (Misc queries) 1 April 12th 05 08:05 PM


All times are GMT +1. The time now is 01:51 AM.

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

About Us

"It's about Microsoft Excel"