3 pièce(s) jointe(s)
Affecter un CHANGE a une combobox dynamique !
Bonjour à tous !
Je réalise un trieur, afficheur de données pour 5 automates (70 capteurs différents) en solution de secours à une défaillance des PC de supervision. Après tri de mes données pour les mettre dans un bon format je veux pouvoir utiliser un filtre avancé parce que c'est vachement bien :p
la structure ressemble donc à ceci :
Pièce jointe 583752
et mon formulaire à ça :
Pièce jointe 583753
Donc je souhaite pouvoir rajouter des capteurs (jusqu'à 12) et ajouter des lignes à mes critères Pièce jointe 583754 en cliquant sur [AJOUTER UN CAPTEUR]
Pour ceci j'utilise ces fonctions :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Private Sub boutton_ajout_capteurs_Click()
'----------------------------------------------------------------------------------------------------------------------------------------------------'
'DECLENCHEMENT ET COMPTAGE DE L AJOUT DE CAPTEURS A TRIER ET AFFICHER'
'----------------------------------------------------------------------------------------------------------------------------------------------------'
Dim nom_boutt As String
nom_boutt = "capt_" & memoire_capt_glob + 1
Call ajout_capteurs(nom_boutt, memoire_capt_glob)
memoire_capt_glob = memoire_capt_glob + 1
Range("J" & memoire_capt_glob + 2).Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[-1]C"
Range("K" & memoire_capt_glob + 2).Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[-1]C"
End Sub |
ET
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| Sub ajout_capteurs(ByVal Nom As String, nbr_capteurs As Integer)
'----------------------------------------------------------------------------------------------------------------------------------------------------'
'UNE FONCTION QUI CREE UN NOUV BOUTT TYPE COMBOBOX ET LE REMPLIT'
'----------------------------------------------------------------------------------------------------------------------------------------------------'
pos_init_x = 96
pos_init_y = 318
hauteur_init = 25
longueur_init = 90
'ajout d'une combobox'
Set nouv_capteur = Form_dates.Controls.Add("Forms.Combobox.1")
nouv_capteur.Name = Nom
MsgBox nouv_capteur.Name
'---------POSITIONNEMENT ET NOMINATION DU NOUVEAU BOUTTON DE CAPTEUR (saut à la ligne tous les 4 capteurs)--------'
nouv_capteur.Width = longueur_init
nouv_capteur.Height = hauteur_init
If nbr_capteurs <= 3 Then
nouv_capteur.Left = pos_init_x + longueur_init * (nbr_capteurs) + 10 * nbr_capteurs
nouv_capteur.Top = pos_init_y
ElseIf nbr_capteurs < 8 Then
nouv_capteur.Left = pos_init_x + longueur_init * (nbr_capteurs - 4) + 10 * (nbr_capteurs - 4)
nouv_capteur.Top = pos_init_y + hauteur_init + 10
ElseIf nbr_capteurs <= 11 Then
nouv_capteur.Left = pos_init_x + longueur_init * (nbr_capteurs - 8) + 10 * (nbr_capteurs - 8)
nouv_capteur.Top = pos_init_y + hauteur_init * 2 + 10 * 2
Else
MsgBox "Une erreur c'est produite. Vous êtes limité à 12 capteurs. Merci de RESET et de recommencer"
Unload Me
End If
'--------CREATION DE LA BONNE TAILLE DE TABLEAU EN FCT DU NOMBRE DE PAGE DE DATASn-------'
With Sheets("DATAS1")
Set Plage1 = .Range("S3:S" & .Range("S1048576").End(xlUp).Row)
End With
If Feuille_Existe("DATAS2") Then
With Sheets("DATAS2")
Set Plage2 = .Range("S3:S" & .Range("S1048576").End(xlUp).Row)
End With
ReDim Tab_capt(1 To Plage1.Count + Plage2.Count)
Else
ReDim Tab_capt(1 To Plage1.Count)
End If
Sheets("DATAS1").Select
For Each cell In Plage1
i = i + 1
Tab_capt(i) = cell
Next
'--------REMPLISSAGE DU NOUVEAU BOUTON CAPTEUR-------'
If Feuille_Existe("DATAS2") Then
Sheets("DATAS2").Select
j = i
For Each cell In Plage2
j = j + 1
Tab_capt(j) = cell
Next
End If
nouv_capteur.List = Tab_capt
nouv_capteur.Change
End Sub |
Alors mon nouveau bouton doit s'appeler capt_ 1 2 3 4 ....
Mais quand je fais un capt_2_Change() la fonction n'est "linké" au bouton et rien ne se déclenche :/
Auriez vous des idées pour solutionner ce problème ?
Merci d'avance à tous ! <3 à vous et bisous