VBA créé une variable à l'aide d'un integer
vincs333
-
yg_be Messages postés 23437 Date d'inscription Statut Contributeur Dernière intervention -
yg_be Messages postés 23437 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour,
Je souhaite pouvoir appeler une procédure sur plusieurs variable
exemple :
Mes variables lot1 , lot2 , ..., lot20 contiennent des données en chiffre elles sont précedemment créés dans mon code
Dim i as integer
for i = 1 to 20 (j'ai aussi essayé for i = "lot" & 1 to "lot" & 20 mais cela me créé un texte et nom une variable utilisable)
ilot = "lot" & i (cela me créé la variable ilot en string (donc non utilisable) et non une variable lot3 par exemple contenent un nombre)
call compterlot(ilot)
next i
Merci d'avance pour vos idées (je suis aussi preneur si vous savez transformer un string en variable utilisable)
Je souhaite pouvoir appeler une procédure sur plusieurs variable
exemple :
Mes variables lot1 , lot2 , ..., lot20 contiennent des données en chiffre elles sont précedemment créés dans mon code
Dim i as integer
for i = 1 to 20 (j'ai aussi essayé for i = "lot" & 1 to "lot" & 20 mais cela me créé un texte et nom une variable utilisable)
ilot = "lot" & i (cela me créé la variable ilot en string (donc non utilisable) et non une variable lot3 par exemple contenent un nombre)
call compterlot(ilot)
next i
Merci d'avance pour vos idées (je suis aussi preneur si vous savez transformer un string en variable utilisable)
A voir également:
- VBA créé une variable à l'aide d'un integer
- Cree un compte google - Guide
- Comment créer un groupe whatsapp - Guide
- Comment cree un compte gmail - Guide
- Crée un qr code - Guide
- Comment créé un compte paypal - Guide
3 réponses
j'utilise deja le controls :
Sub saisielot()
saisie = 0
For i = 1 To 36
ilot = (i * 3) - 2
Call compterlot(ilot, i, lot)
If lot <> 0 And saisie = 0 Then
lot1 = lot
nom1 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 1 And nom1 <> UserForm2.Controls("textbox" & ilot) Then
lot2 = lot
nom2 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 2 And nom2 <> UserForm2.Controls("textbox" & ilot) Then
lot3 = lot
nom3 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 3 And nom3 <> UserForm2.Controls("textbox" & ilot) Then
lot4 = lot
nom4 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 4 And nom4 <> UserForm2.Controls("textbox" & ilot) Then
lot5 = lot
nom5 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 5 And nom5 <> UserForm2.Controls("textbox" & ilot) Then
lot6 = lot
nom6 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 6 And nom6 <> UserForm2.Controls("textbox" & ilot) Then
lot7 = lot
nom7 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 7 And nom7 <> UserForm2.Controls("textbox" & ilot) Then
lot8 = lot
nom8 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 8 And nom8 <> UserForm2.Controls("textbox" & ilot) Then
lot9 = lot
nom9 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 9 And nom9 <> UserForm2.Controls("textbox" & ilot) Then
lot10 = lot
nom10 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
Next i
For jlot = "lot" & 1 To "lot" & 10
call laprocedurequejesouhaite(jlot) <------------------------- c'est ici mon probleme
Next jlot
End Sub
Sub compterlot(ilot, i, lot)
lot = 0
blocage5 = 0
For g = 1 To 36
glot = (g * 3) - 2
If glot > ilot Then
If UserForm2.Controls("textbox" & ilot) <> UserForm2.Controls("textbox" & glot) And blocage5 = 0 Then
lot = g - i
blocage5 = 1
End If
End If
If g = 36 And blocage5 = 0 And UserForm2.Controls("textbox" & glot) <> Empty Then
lot = g - i + 1
End If
Next g
End Sub
Sub saisielot()
saisie = 0
For i = 1 To 36
ilot = (i * 3) - 2
Call compterlot(ilot, i, lot)
If lot <> 0 And saisie = 0 Then
lot1 = lot
nom1 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 1 And nom1 <> UserForm2.Controls("textbox" & ilot) Then
lot2 = lot
nom2 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 2 And nom2 <> UserForm2.Controls("textbox" & ilot) Then
lot3 = lot
nom3 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 3 And nom3 <> UserForm2.Controls("textbox" & ilot) Then
lot4 = lot
nom4 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 4 And nom4 <> UserForm2.Controls("textbox" & ilot) Then
lot5 = lot
nom5 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 5 And nom5 <> UserForm2.Controls("textbox" & ilot) Then
lot6 = lot
nom6 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 6 And nom6 <> UserForm2.Controls("textbox" & ilot) Then
lot7 = lot
nom7 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 7 And nom7 <> UserForm2.Controls("textbox" & ilot) Then
lot8 = lot
nom8 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 8 And nom8 <> UserForm2.Controls("textbox" & ilot) Then
lot9 = lot
nom9 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
If lot <> 0 And saisie = 9 And nom9 <> UserForm2.Controls("textbox" & ilot) Then
lot10 = lot
nom10 = UserForm2.Controls("textbox" & ilot)
saisie = saisie + 1
End If
Next i
For jlot = "lot" & 1 To "lot" & 10
call laprocedurequejesouhaite(jlot) <------------------------- c'est ici mon probleme
Next jlot
End Sub
Sub compterlot(ilot, i, lot)
lot = 0
blocage5 = 0
For g = 1 To 36
glot = (g * 3) - 2
If glot > ilot Then
If UserForm2.Controls("textbox" & ilot) <> UserForm2.Controls("textbox" & glot) And blocage5 = 0 Then
lot = g - i
blocage5 = 1
End If
End If
If g = 36 And blocage5 = 0 And UserForm2.Controls("textbox" & glot) <> Empty Then
lot = g - i + 1
End If
Next g
End Sub