ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calling objects (https://www.excelbanter.com/excel-programming/283641-calling-objects.html)

Stewart[_3_]

Calling objects
 
I have some textboxes named TB1 thorugh to TB10. I want to
call these text boxes using a for-next loop. How can I
make this work? This is kind of what I want to happen, but
it obviously doesn't work...

for a =1 to 10
TB a .value="Whatever"
next a

Thank you for any help you can give me on this matter!!!

Stewart
MOS Excel Expert (not that it's doing me much good!!!)

Rob Bovey

Calling objects
 
Hi Stewart,

Here's one way to do it:

Dim lCount As Long
For lCount = 1 To 10
Me.Controls("TB" & CStr(lCount)).Value = lCount
Next lCount

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Stewart" wrote in message
...
I have some textboxes named TB1 thorugh to TB10. I want to
call these text boxes using a for-next loop. How can I
make this work? This is kind of what I want to happen, but
it obviously doesn't work...

for a =1 to 10
TB a .value="Whatever"
next a

Thank you for any help you can give me on this matter!!!

Stewart
MOS Excel Expert (not that it's doing me much good!!!)





All times are GMT +1. The time now is 06:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com