
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim campo, colA As Range
Set campo = Range("B1:D10") 'da modificare col proprio range
Set colA = Range("A1:A10") 'da modificare col proprio range
colA.Interior.Color = xlNone
For i = 1 To 10
For Each cell In campo
If cell.Value = Cells(i, 1).Value Then
Cells(i, 1).Interior.Color = cell.Interior.Color
End If
Next
Next i
End Sub |
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim campo, origine, cell As Range, i, j As Integer
Set campo = Union(Range("A9:A38"), Range("E9:E38"), Range("H9:H38"))
Set origine = Range("K12:T24")
campo.Interior.Color = xlNone
For j = 2 To 8 Step 3
For i = 9 To 38
For Each cell In origine
If cell.Value = Cells(i, j).Value Then
Cells(i, j).Interior.Color = cell.Interior.Color
End If
Next
Next i
Next j
End Sub
|
Option Explicit
Sub conteggi()
Dim rng1, cell As Range
Dim i, tot As Integer
Set rng1 = Union(Range("B9:B38"), Range("E9:E38"), Range("H9:H38"))
For i = 3 To 5
tot = 0
For Each cell In rng1
If Range("I" & i).Interior.ColorIndex = cell.Interior.ColorIndex Then
tot = tot + 1
End If
Next
Range("J" & i).Value = tot
Next i
End Sub |
Option Explicit
Sub colori()
Dim campo, origine, cell As Range, i, j, tot As Integer
Set campo = Union(Range("B9:B38"), Range("E9:E38"), Range("H9:H38"))
Set origine = Range("L12:P24")
origine.Interior.Color = xlNone
For j = 2 To 8 Step 3
For i = 9 To 38
For Each cell In origine
If cell.Value = Cells(i, j).Value Then
cell.Interior.Color = Cells(i, j).Interior.Color
End If
Next
Next i
Next j
For i = 3 To 5
tot = 0
For Each cell In campo
If Range("I" & i).Interior.ColorIndex = cell.Interior.ColorIndex Then
tot = tot + 1
End If
Next
Range("J" & i).Value = tot
Next i
End Sub |
