8 gru 2012

Kolorowanie komórek w Excelu

' With Worksheets(1).Range("n1:q40")
' With ActiveSheet.Range("o1:r45")
' With ActiveSheet.UsedRange
With Selection
Set c = .Find(1, LookIn:=xlValues)
Dim firstAddress
If Not c Is Nothing Then
firstAddress = c.Address
Do
' c.Value = 8
' c.Interior.Color = 65432
c.Interior.ColorIndex = 27
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

Kolorowanie komórek w Excelu. W pętli następuje sprawdzenie wartości komórki, jeżeli jest 1 kolor komórki ustawiany jest na żółty. Kolorwanie wykonywane jest na zaznaczonym myszką obszarze Excela.