0

Could any one direct me in right direction for the following code? I want to create a text box at run time by row & column.The following creates only a row & not multiple rows. I want the columns to remain same & just keep increasing rows. Thanks in advance :)

    Dim txtB1 As Control
    Dim i
    For i = 0 To 4
    Set txtB1 = UserForm.Controls.Add("Forms.TextBox.1")
    With txtB1
        .Name = "chkDemo" & i
        .Height = 20
        .Width = 50
        .Left = 30 * i * 2
        .Top = 15
        .ControlTipText = "Type of Bug"
        End With
    Next i

1 Answer 1

3

You need a For loop for each dimension (rows and columns).

Dim txtB1 As Control
Dim i, jrow

For jrow = 1 To 5
    For i = 0 To 4
        Set txtB1 = UserForm.Controls.Add("Forms.TextBox.1")
        With txtB1
        .Name = "chkDemo" & i
        .Height = 20
        .Width = 50
        .Left = 50 * i + 2
        .Top = 20 * jrow + 15
        .ControlTipText = "Type of Bug"
        End With
    Next i
Next jrow

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.