So, a few days ago I stopped by to see if there was a way to use the .Find method with cell shadings, or ColorIndex values, and got this little bit of code punched up (thanks to Noob):
Application.FindFormat.Interior.ColorIndex = 4
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=True).Activate
Cells.FindNext(After:=ActiveCell).Activate
So now I'm trying to figure out how to loop this for the scope of a worksheet automatically, but the trouble seems to be that, when the search reaches the last cell with that particular ColorIndex value, it loops back to the top again.
A previous .Find loop I had set up was this:
With ActiveSheet.Cells
Set startpos = .Find(What:=StartDate, After:=Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlPart, _
Searchorder:=xlRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not startpos Is Nothing Then
Temp1 = startpos.Address
Do
(... Code in here... )
Set startpos = .FindNext(startpos)
Loop While Not startpos Is Nothing And startpos.Address <> Temp1
End If
End With
That second bit of code works well, but I don't know how to store a ColorIndex variable or something, whatever it's going to take to actually get this loop put together. All I'd like it to do is the same activity, to every cell shaded that particular color, and then, when it's hit them all, I want it to quit.
Any way this works out? I'm really unfamiliar with the ColorIndex property.
Thanks!
Bookmarks