Fill Textboxes Dynamically

  • Hi All,

    I have a large number of textboxes on a sheet and they will be filled with information from a sheet.

    so for example

    Me.TextBox1.Value = Sheets("menu_numbers").Range("a2").Value
    Me.TextBox2.Value = Sheets("menu_numbers").Range("a3").Value

    Is there a way of filling the textboxes without having to name each cell individually like the above. I don't think there will be, but here is hoping someone will drop a knowledge bomb on me.

    Thanks in advance

    End Sub

  • Re: Fill Textboxes Dynamically


    You could test the following :

    Dim i As Long 
    For i = 1 To 30 
        Me.Controls("TextBox" & i).Value = Sheets("menu_numbers").Range("A" & i +1).Value 
    Next i


    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, below, in the bottom right corner :)

  • Re: Fill Textboxes Dynamically

    Just throwing in an update to the reply in your other thread to illustrate a concept.

    There's a list in Col H, Highlight some of the items and click the button. The highlighted items will be loaded to the userform, along with any values in Col I. You can edit in the userform, clicking the userform button updates the worksheet.

    The selection need not be contiguous - you can select, for example, cells H1-H9, H13-H15, H20, H23... All will be updated correctly.

  • Re: Fill Textboxes Dynamically

    So in theory cytop, i could make this a macro to automate the process and select all cells in the column that contain data using vba and do the same thing?

  • Re: Fill Textboxes Dynamically

    Hi Carim, Thanks for your reply,

    In order to make this only select cells with data in i assume i would need to change the i= part.

    Would it look something like

    lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
    for i = 1 to lastrow
  • Re: Fill Textboxes Dynamically

    You don't have to select anything, you could easily modify it to pass a range instead.

    If I get a chance later I'll tidy it up, but a copy of your workbook would be useful to put it in context.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!