I have a vba code that has been assigned to a button named as "run report". Have some instructions with check boxes and what I am trying to do is to enable button only if all the checkboxes are ticked. I tried something like below but somehow it's not working. It seems something is wrong with declaration. I am using ms office 2013 version.
Sub buttonenable()
Dim B1 as Button
Dim C1 as Checkbox
Dim C2 as Checkbox
Dim C3 as Checkbox
Set B1 = Thisworkbook.Sheets("Home").Button("Run report")
Set C1 = Thisworkbook.Sheets("Home").Checkbox("Checkbox1")
Set C2 = Thisworkbook.Sheets("Home").Checkbox("Checkbox2")
Set C3 = Thisworkbook.Sheets("Home").Checkbox("Checkbox3")
IF C1 = True and C2 = True and C3 = True Then
B1.Enable = True
Else
B1.enable = False
End If
End Sub()
Aucun commentaire:
Enregistrer un commentaire