
Sub YellowRange()
Dim TotalRange As Range, MyYellowRange As Range, cell As Range, i As Byte, matrixY() As String
Set TotalRange = Range("a1").CurrentRegion
i = 1
For Each cell In TotalRange
If cell.Interior.ColorIndex = 6 Then
ReDim Preserve matrixY(1 To i)
matrixY(i) = cell.Address
i = i + 1
End If
Next
' Assegno a MyYellowRange il Range con solo le celle in giallo.
Set MyYellowRange = Range(Join(matrixY, ","))
For Each cell In MyYellowRange
'---- ecc ecc
Next
End Sub
|
Sub YellowRange()
Dim TotalRange As Range, MyYellowRange As Range, cell As Range, i As Byte, matrixY() As String
Set TotalRange = Range("a1").CurrentRegion
For Each cell In TotalRange
If cell.Interior.ColorIndex = 6 Then
' Assegno a MyYellowRange il Range con solo le celle in giallo.
If MyYellowRange Is Nothing Then
Set MyYellowRange = cell
Else
Set MyYellowRange = Union(MyYellowRange, cell)
End If
End If
Next
MsgBox "My Yellowrange: " & MyYellowRange.Address, , MyYellowRange.Cells.Count & " cells"
For Each cell In MyYellowRange
'---- ecc ecc
Next
End Sub |
