简体   繁体   中英

create text box by row & column on a userform vba

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

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:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM