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: 3
Default How to cycle through a series of similar objects with a for-next loop?

I am an occasional programmer and I would like some help on a problem:

I have 20 existing object labels on an Excel 2000 worksheet. They were
initially added with no attention to their caption property. I need these
labels to contain calculated data that periodically changes. My existing
code to update these labels has 20 lines like this:

txtX1.Caption = <some calculation
txtX2.Caption = <some calculation
..
..
..
txtX20.Caption = <some calculation

I want to use something more elegant like a for-next loop, but I can't seem
to figure how to dynamically change the label object reference from txtX1 to
txtX2 to txtX3 (and so on) on each iteration of the for-next loop. If I
assemble a reference as a string variable and append the .Caption, it
generates a runtime error. What is the proper method for handling a task
like this? I have often had to handle problems like this using the above
method, but I'm sure there must be a better solution.

Regards,
Derrick.


 
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
Seperate data series on a similar X-axis Enzo Matrix Charts and Charting in Excel 2 January 11th 07 05:15 PM
Toggle Chart Series Objects On/Off Raul Charts and Charting in Excel 2 May 20th 06 04:43 PM
Excel formula similar to a loop in Basic? Cashtime Excel Worksheet Functions 2 February 6th 05 07:53 PM
Loop through objects/controls on worksheet Tom V Excel Programming 2 September 16th 04 06:09 PM
loop through form objects Steven K Excel Programming 1 August 23rd 04 07:47 PM


All times are GMT +1. The time now is 03:40 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"