PDA

View Full Version : Numbered Text boxes managed by Loop or for?



danovkos
02-29-2016, 12:28 AM
Hi,
i have userform. In my UF aj i have 15 rows with many textboxes. Each row has TB like TBcif, TBmeno, TBang, TBdovd.
Because i have 15 rows, every rows has same number of TB. So 1. row is TBcif1..., second TBcif2....
I use also some actions, when TBcif is exiting. Look in my code.
I make some actions in rows when is handled with rows. I mean, when i make something in row3, then makes some actions in row 3 and so.
Now my questions.
Sometimes i insert some new actions (code) which i want to do with rows. Problem is, that i have to put in every Private sub, which i have for every row because every row has other number. Name of my textboxes are the same, but number is base row.
Is any option, how to make it in loop or so?

This is code for my TB. Then i have another 14 Private sub with number 2 till 15.



Private Sub TBcif1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Set ALL = Workbooks(PrehladyNAMEVp).Sheets("ALL").Range("C55:K30000")
If TBcif1 = "" Then TBcif1 = 0
Cifko = Abs(CDec(TBcif1))

If IsError(Application.vlookup(Cifko, ALL, 2, 0)) = False Then
TBmeno1.Value = Application.vlookup(Cifko, ALL, 2, 0)
TBcif1.ForeColor = 0
Else
TBcif1.ForeColor = 3355597
End If
End Sub


I tried something like this, which i have in other macros, but this of course didnt works.


For ii = 1 To 8
Set Meno = Me.Controls("Label_menoVazba" & ii)
Set Cifko = Me.Controls("TB_cif" & ii)
Set UverNEuver = Me.Controls("COMBO_neuvUver" & ii)
Set Angazovanost = Me.Controls("AngazovanostOM" & ii)
Set produktik = Me.Controls("COMBO_produkt" & ii)
Set Dovod = Me.Controls("DovodOM" & ii)
Set OPUCKO = Me.Controls("COMBO_OPU" & ii)
Set OKorNOok = Me.Controls("okNOok" & ii)
next


thx for help