Find Cells with Specific Format

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.
 
J

Jim Parsells

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top