Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a series of labels on a form that I want to change the text
color on programatically. If the label names are like 'label1', 'label2','label3', is there a a way to loop through them? Albert Wang |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() You can loop through them as members of the Controls collection Dim ctl As Control For Each ctl In Me.Controls If ctl.Name = "Label2" Then Me.Label2.ForeColor = vbRed End If Next ctl -- Kevin Backmann "AlbertYWang" wrote: I have a series of labels on a form that I want to change the text color on programatically. If the label names are like 'label1', 'label2','label3', is there a a way to loop through them? Albert Wang |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
some added info:
Dim ctl As Control For Each ctl In Me.Controls if typeof ctl is MSForms.Label then Me.Label2.ForeColor = vbGreen End If Next ctl or for i = 1 to 5 me.controls("Label" & i).ForeColor = RGB(0,255,0) Next -- Regards, Tom Ogilvy "Kevin B" wrote in message ... You can loop through them as members of the Controls collection Dim ctl As Control For Each ctl In Me.Controls If ctl.Name = "Label2" Then Me.Label2.ForeColor = vbRed End If Next ctl -- Kevin Backmann "AlbertYWang" wrote: I have a series of labels on a form that I want to change the text color on programatically. If the label names are like 'label1', 'label2','label3', is there a a way to loop through them? Albert Wang |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Kevin and Tom.
That's exactly what I needed. Albert Wang Tom Ogilvy wrote: some added info: Dim ctl As Control For Each ctl In Me.Controls if typeof ctl is MSForms.Label then Me.Label2.ForeColor = vbGreen End If Next ctl or for i = 1 to 5 me.controls("Label" & i).ForeColor = RGB(0,255,0) Next -- Regards, Tom Ogilvy "Kevin B" wrote in message ... You can loop through them as members of the Controls collection Dim ctl As Control For Each ctl In Me.Controls If ctl.Name = "Label2" Then Me.Label2.ForeColor = vbRed End If Next ctl -- Kevin Backmann "AlbertYWang" wrote: I have a series of labels on a form that I want to change the text color on programatically. If the label names are like 'label1', 'label2','label3', is there a a way to loop through them? Albert Wang |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Questions about Forms & Controls | Excel Discussion (Misc queries) | |||
Forms controls | Excel Worksheet Functions | |||
Forms Controls | Excel Programming | |||
diference between FORMS & CONTROLS | Excel Programming | |||
Forms Controls | Excel Programming |