Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Labels and Captions

Hey all,
I realize this should be easy, but I'm not finding the solution.
I have labels that are named Label1, Label2, Label3, ...

I want a loop to set the label's caption such as
For i = 1 to 5
Label(i).caption = "My Caption"
Next i

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Labels and Captions

For i = 1 To 5
Controls("Label" & i) = "My Caption"
Next iCt

Merjet

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Labels and Captions

Assuming you have exactly 5 label controls and they all are named as LabelX,

Dim i As Integer
For i = 1 To 5
Me.Controls("Label" & i).Caption = "My Caption"
Next i


If you wanted to just go through all label controls in the form, then
something like this might give you an idea

Dim c as control
For each c in Me.Controls
If TypeOf c is MSForms.Label then
c.Caption = "My Caption"
End If
Next c



" wrote:

Hey all,
I realize this should be easy, but I'm not finding the solution.
I have labels that are named Label1, Label2, Label3, ...

I want a loop to set the label's caption such as
For i = 1 to 5
Label(i).caption = "My Caption"
Next i

Thanks


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
X axis captions Stefi Charts and Charting in Excel 6 September 11th 08 01:16 PM
Userform Captions Greg[_27_] Excel Programming 3 May 23rd 06 07:23 PM
Clear Captions from labels Spencer Hutton[_4_] Excel Programming 5 November 20th 04 08:54 PM
clear captions from all labels Spencer Hutton[_4_] Excel Programming 3 November 20th 04 01:49 PM
reset menu captions T Excel Programming 2 November 12th 04 11:28 AM


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

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"