LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Loop through Labels and Text Boxes within module code

I am trying to change Label Captions and Text Box Text in a loop located in
my module. For example I have a form that has 40 labels. I want to change the
text in the first "m" number of labels. At first I was hopeing to use
something like the following

for i = 1 to m
UserForm1."Label" & i.Caption = worksheets("Sheet1").cells(3,i).value
Next i

Excell does not seam to want to consummate "Label" & i to Label1 and
recognize it as a object within UserForm1. At the suggestion of a buddy and
another posting I was hopeing to do it defining a collection of Label objects
with the following code, however the "Set" statement doesn't seam to be valid
for a collection.

Dim Labs() As New Collection

Dim labelcount As Integer
Dim ctl As Control

labelcount = 0
For Each ctl In UserForm1.Controls
If TypeName(ctl) = "Label" Then
labelcount = labelcount + 1
ReDim Preserve Labs(1 To labelcount)
Set Labs(labelcount) = ctl
End If
Next ctl

For i = 1 To m
Labs(i).Caption = "cool"
Next i

I would appreciate any help on the matter, the end less dead ends are
driving me to madness. I'm useing Office 2000 and am upgradeing to Office 2003

 
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
Data labels switch to text boxes on negative values Cooter Charts and Charting in Excel 3 May 1st 08 09:42 PM
code in module A to not execute a Worksheet_SelectionChange sub of another module Jack Sons Excel Discussion (Misc queries) 4 December 11th 05 11:52 PM
XL97: Position text boxes (or data labels) w/out VBA LeAnne Charts and Charting in Excel 1 December 1st 05 09:07 PM
MSForm 2 - Creating labels and text boxes at run time Tim Coddington Excel Programming 2 October 1st 04 03:03 PM
Updating form labels from code in a module news.verizon.net[_2_] Excel Programming 2 October 29th 03 04:03 AM


All times are GMT +1. The time now is 10:46 PM.

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"