Share via

Quick VBA code for finding cells based on .interior.pattern (or other formatting examples)

Anonymous
2017-02-13T13:25:03+00:00

Hi There!

I'm looking for help regarding a quick way to find a cell based on its interior.pattern.

I realise I can do a "For Each Cell" to loop though every cell and check with an If command, but I have hundreds of columns and I'm looking for a fast way to do it.

Ideally something similar to a .Find() command, but replacing the string of "What:=" with the interior.pattern would be perfect, but anything that's faster than looking through each cell will be much appreciated!

Thanks for the help!

P.s If someone could also tell me how to insert code snippets in the question that would be helpful!

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-02-13T18:06:06+00:00

H,

re:  find cell with a particular format

Finds top most cell in columns "H:L" with Red interior color.

Additional "FindNext" code required to find more cells.

SearchFormat is True in order to utilize FindFormat setting.

'---

Sub FindFirstColor()

  Dim rngFound As Range

  Dim rngToSearch As Range

  Set rngToSearch = ActiveSheet.Columns("H:L")

  Application.FindFormat.Clear

  Application.FindFormat.Interior.Color = vbRed

  Application.FindFormat.Locked = True

  Set rngFound = rngToSearch.Find(what:=vbNullString, searchformat:=True)

  rngFound.Select

End Sub

'---

Jim Cone

Portland, Oregon USA

https://goo.gl/IUQUN2 (Dropbox)

(free & commercial excel add-ins & workbooks)

Was this answer helpful?

0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2017-02-14T11:35:29+00:00

    Worked like a charm! Thanks for your help!

    Was this answer helpful?

    0 comments No comments