Find Cells with Specific Format

  • Thread starter Thread starter Jim Parsells
  • Start date Start date
J

Jim Parsells

I am trying to find cells in a specific range with a specific Border
configuration. This should be simple, but the following code does not work.
It finds the first such cell OK, but then proceeds to find only empty cells
with no borders. This is with Office Pro 2003.

Sub FindFirstLine()
Worksheets("Sheet1").Activate
ActiveSheet.Range("A:A").Select
Application.FindFormat.Clear
With Application.FindFormat.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
With Selection
Set c = .Find(What:="", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=True)
If Not c Is Nothing Then
firstAddress = c.Address
Do
Debug.Print c.Address; Tab; c.Value
Set c = .FindNext(c)
If c Is Nothing Then Exit Do
Loop While c.Address <> firstAddress
End If
End With
End Sub

Any help will be appreciated.
 
Never mind. I found the answer in this forum by Dave Peterson dated 4/27/08
in reply to msg losing Application.FindFormat.Num...
Thanks Dave.
 
Back
Top