VBA créé une variable à l'aide d'un integer
Fermé
vincs333
-
12 mai 2018 à 18:43
yg_be Messages postés 23471 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 15 février 2025 - 12 mai 2018 à 22:51
yg_be Messages postés 23471 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 15 février 2025 - 12 mai 2018 à 22:51
A voir également:
- VBA créé une variable à l'aide d'un integer
- Cree un compte google - Guide
- Comment créer un groupe whatsapp - Guide
- Créer un compte gmail - Guide
- Créer un compte instagram sur google - Guide
- Créer une adresse hotmail - Guide
3 réponses
NHenry
Messages postés
15190
Date d'inscription
vendredi 14 mars 2003
Statut
Modérateur
Dernière intervention
11 février 2025
353
12 mai 2018 à 18:47
12 mai 2018 à 18:47
Utilise un tableau, c'est plus adapté pour cet usage.
Je ne peux pas c'est un fichier word qui importe des données dans des fichiers excels (planning, rotation de lot de fabrication pour une usine) je les "sauvegarde temporairement" dans des textbox pour traiter les données et enfin les implanter dans un tableau "word" pour qu'il soit imprimer
NHenry
Messages postés
15190
Date d'inscription
vendredi 14 mars 2003
Statut
Modérateur
Dernière intervention
11 février 2025
353
12 mai 2018 à 18:53
12 mai 2018 à 18:53
Tu peux regarder la collection "Controls" de ta userform alors.
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
yg_be
Messages postés
23471
Date d'inscription
lundi 9 juin 2008
Statut
Contributeur
Dernière intervention
15 février 2025
1 568
12 mai 2018 à 22:51
12 mai 2018 à 22:51
bonsoir, utiliser un tableau, c'est faire
tlot(1) = lotau lieu de
lot1 = lot, et ensuite,
ilot = tlot(i)