PDA

View Full Version : Solved: Find by cell format



RECrerar
10-19-2007, 04:51 AM
Is it possible to do a Find based on the format of the cell. basically I want to search for cells in a specific column that are in Bold. Currently I'm doing a check on every cell in the column but a 'find' or equivalent method would be much more efficient.

Oorang
10-20-2007, 11:28 AM
Just cheat and use the macro recorder to record your find by format search (ctrl-f) You'll get something like this: Application.FindFormat.Interior.ColorIndex = 6
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
, SearchFormat:=True).Activate

Cyberdude
10-20-2007, 03:21 PM
OK, oorang, I give up . . . how does this work?
Sub FindCellWithFormat()
Application.FindFormat.Interior.ColorIndex = 6

Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=True).Activate

MsgBox Selection.Address
End Sub How does the Find method know what to look for?? I don't see how the find criteria is given to the Find method. This is pretty slick, but I just don't get it.
Sid

Bob Phillips
10-20-2007, 05:39 PM
The first line of the code sets an application property. Look it up in VBA help, and all will be clear.

RECrerar
10-22-2007, 06:54 AM
Hey thanks for that, I didn't even know you could do that normally, so thanks, have recorded the find, and working as it should

Oorang
10-24-2007, 08:54 AM
I R teH cheeTaR:uptosomet

http://www.vbaexpress.com/forum/images/icons/icon10.gif