Search code examples
vbaobjecttextboxuserform

Unhiding textboxes


I would like to ask you to help me with textboxes in userform. I have 3 multipgaes, first one is used to enter input data. Second one is to insert invoice number and amounts for each invoice. I have there 200 textboxes, but only 24 are visible (12 for invoice number and 12 for amount). This page contains checkbox in case somebody wants to enter more than 12 invoices. How can I unhide all those invoices with VBA code? I don't want to copy paste the same code almost 200 times: me.tb1.visible = true, me.tb2.visible = true ... I tried it with cycle but doesn't work:

for i = 13 to 100
   me.tb(i).visible = true
next i

I was trying to find something like

dim Utextbox as textbox

for each Utextbox in VBA.userforms
    [code]
next 

Please help me to solve this issue. Thank you


Solution

  • You were very close! Try this:

    For i = 13 To 100
       Me.Controls("tb" & i).Visible = True
    Next