I have a problem with my option buttons linked cells. I'd like to load a macro whenever the value of the linked cell changes. I tried two different methods, and none of them won't work when the button changes the value. If I type in a selected cell a value, my macros do load.
Here are my two techniques:
Private Cel_CONGESg As Byte
Private Sub Worksheet_Calculate()
Dim Ws As Worksheet
Set Ws = ThisWorkbook.Sheets("Externe")
If Ws.Range("$I$12").Value <> Cel_CONGESg Then
MsgBox "heheheheeheheheheee"
End If
Cel_CONGESg = Ws.Range("$I$12").Value
End Sub
The second method
Private Sub Worksheet_Change(ByVal target As Range)
Dim CongesG
Dim Ws As Worksheet
Set CongesG = Ws.Range("$I$12")
If Not Application.Intersect(CongesG, Range(target.Address)) _
Is Nothing Then
If Ws.Range("$I$12").Value = 2 Or Ws.Range("$I$12").Value = 0 Then
Ws.Range("$I$13").EntireRow.Hidden = True
With Range("H12:L12").Borders(xlEdgeBottom)
.LineStyle = xlDot
.Color = RGB(51, 63, 79)
.Weight = xlThin
End With
ElseIf Ws.Range("$I$12").Value = 1 Then
Ws.Range("$I$13").EntireRow.Hidden = False
With Range("H12:L12").Borders(xlEdgeBottom)
.LineStyle = xlNone
End With
End If 'I12 Congés
End If 'Application intersect CongesG
End Sub
Could you please help me understand what's the problem?
Thank you in advance. Have a great day.
Jean