- Codice: Seleziona tutto
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CheckArea1 As String
Dim CheckArea2 As String
Dim CheckArea3 As String
Dim bTarget As Boolean
CheckArea1 = "B3:D3, B7:D7,B11:D11,B15:D15,B19:D19,B23:D23,B27:D27,B31:D31,G5:I5,G13:I13,G21:I21,G29:I29,L9:N9,L25:N25"
CheckArea2 = "A3, A7, A11, A15, A19, A23, A27, A31, F5, F13, F21, F29,K9, K25 "
CheckArea3 = "E3, E7, E11, E15,E19, E23, E27, E31, J5, J13, J21, J29, O9, O25"
With Target
If .Cells.Count > 1 Then Exit Sub
If Not Application.Intersect(Target, Me.Range(CheckArea1)) Is Nothing Then
If .Interior.ColorIndex = 3 Then
.Interior.ColorIndex = xlNone
Else
.Interior.ColorIndex = 3
End If
bTarget = True
ElseIf Not Application.Intersect(Target, Range(CheckArea2)) Is Nothing Then
If ActiveCell.Interior.ColorIndex = 6 Then
ActiveCell.Interior.ColorIndex = xlNone
Else
ActiveCell.Interior.ColorIndex = 6
End If
bTarget = True
ElseIf Not Application.Intersect(Target, Range(CheckArea3)) Is Nothing Then
If Target = "V" Then
Target = ""
Else
Target = "V"
End If
bTarget = True
End If
If bTarget Then
Application.EnableEvents = False
Me.Range("G1").Select 'oppure .Offset(0, 1).Select
Application.EnableEvents = True
End If
End With
End Sub