ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can any controls name concatenated? (https://www.excelbanter.com/excel-programming/380047-re-can-any-controls-name-concatenated.html)

Dave Peterson

Can any controls name concatenated?
 
If you know the names and the number of textboxes:

Option Explicit
Private Sub UserForm_Initialize()
Dim iCtr As Long
For iCtr = 1 To 10
Me.Controls("Txtbox" & iCtr).Value = "all the same"
Next iCtr
End Sub




Richard wrote:

Hi,

Hope someone can help me with this.

Here is the Example that I'm trying to do.

Example
assume there is the text box controls such as txtbox1, txtbox2, txtbox3,
txtbox4, txtbox5, etc...

Private Sub UserForm_Initialize()

Dim ctrTextbox As Controls

For i = 1 To 10

ctrTextbox = "txtbox" & i
Me.ctrTextbox = "All text box have same value"

Next i

End Sub

With above coding, I'm getting Complie error: "Argument not optional"

Any help will be appreciated.

Thanks


--

Dave Peterson


All times are GMT +1. The time now is 09:48 PM.

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