Caption checkbox feuille dans variable public
Bonsoir,
J'ai 45 checkbox sur une feuille (checkbox activex), je voudrai récupérer le caption dans une variable public à réutiliser dans une autre macro.
Voici le code d'une seule checkbox sur la feuille (le code est le même pour les 45 checkboxs)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| Dim App, etat
Private Sub Chk17_Click()
etat = Chk17.Value
App = Chk17.Caption
If etat = True Then
MsgBox App & " est en service"
testOn
ElseIf etat = False Then
MsgBox App & " est hors-service"
testOff
End If
End Sub |
Je parviens pas à récupérer le caption pour executer la macro ci-dessous
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| Public App
Sub testOn()
Dim myRange As Range, myCell As Range
MsgBox App
With Sheets("bd")
'aa = "tt16"
Set myRange = Columns(7).Find(App, lookat:=xlPart)
If Not myRange Is Nothing Then
Set myCell = myRange
Do
myRange.Offset(, 5).Value = "En Service"
Set myRange = Columns(7).FindNext(myRange)
Loop Until myRange.Address = myCell.Address
End If
End With
MsgBox "terminé!"
End Sub |
En vous remerciant par avance, par la même occasion est-il possible d'avoir un seul code pour les 45 checkbox_clic?
Cordialement,