View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Parsells Jim Parsells is offline
external usenet poster
 
Posts: 7
Default Find Cells with Specific Format

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.
--
Jim Parsells