View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
moon[_3_] moon[_3_] is offline
external usenet poster
 
Posts: 5
Default How to using Range ?

How to using Range selection to check cell have formated using "color
index=35".

Sub Macro1()
With Selection.Interior
.ColorIndex = 35
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
End With
End Sub

Step1 . Select a area by rows.
Step2. Run sub ErCheckColor

How to write below code to check cell have formated with color index =35, if
not selected row set "0" otherwise set "1".

Sub ErCheckColor()
areaCount = Selection.Areas.Count
If areaCount <= 1 Then
MsgBox "The selection contains " & _
Selection.Rows.Count & " rows."

Else
I = 1
For Each a In Selection.Areas
MsgBox "Area " & I & " of the selection contains " & _
a.Rows.Count & " rows."
I = I + 1

Next a
End If

End Sub