dagan
dagan

Reputation: 215

Search for Cell in A range by Color and Select it

I am trying to serach for a cells by color and select them one by one to copy their values.

I have this so far. But I am just crashing excel with this

Sub searchcol()

Range("O3:O2555").Select
With Application.FindFormat.Interior
    .PatternColorIndex = 6
 End With
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=True).Select

' do copy operation for each cell in this range End Sub

Upvotes: 0

Views: 2026

Answers (1)

Paul
Paul

Reputation: 11

This will go to each cell and check the colour, if it is equal to 65535 (Yellow) it will print the value in the immediate window. You could amend the code to put the values elsewhere. Hope this helps.

Range("O3").Select
Do While ActiveCell.Value <> ""
    If ActiveCell.Interior.Color = 65535 Then
        Debug.Print ActiveCell.Value
    End If
    ActiveCell.Offset(1, 0).Select
Loop

Upvotes: 1

Related Questions