Search for colorindex=6

  • Thread starter Thread starter Dale
  • Start date Start date
D

Dale

Newbee

I would like to have a small program search a sheet for a cell in
column B with the colorindex = 6. If it finds such a cell, make that
the activecell and end the macro. Any thoughts ?
 
For Each cell In Columns("B:B")
If cell.Interior.Colorindex=6 Then
cell.Select
Exit Sub
End If
Next cell

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
The following should work:

Dim rngCell As Range
For Each rngCell In ActiveSheet.Columns(2).Rows
If rngCell.Interior.ColorIndex = 6 Then rngCell.Activate: Exit Sub
Next rngCell

Hope this helps.
 
Sub Activate6()
Dim cell as Range
for each cell in activesheet.UsedRange
if cell.interior.ColorIndex = 6 then
cell.Activate
exit sub
end if
Next
End Sub
 
Sorry, missed the column B specification Assumes the used range starts in
Column A.

Sub Activate6()
Dim cell as Range
for each cell in activesheet.UsedRange.Columns(2).Cells
if cell.interior.ColorIndex = 6 then
cell.Activate
exit sub
end if
Next
End Sub
 
Back
Top