Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default FindFormat with Borders not Working

I'm using this code to look for cells with borders turned on. If I
replace the code with .Font or .Interior.ColorIndex properties, it
finds the appropriate cells. However when I change the code to look for
..Borders properties, there aren't any cells found.

Sub test()

'select cells with thick borders only

Dim firstcell As Range
Dim foundcell As Range
Dim allcells As Range

'specify the formatting to look for
With Application.FindFormat
.Clear
' .Font.Bold = True
' .Interior.ColorIndex = 6 'yellow
' .Font.Name = "Courier"
.Borders.LineStyle = xlEdgeTop
End With

'look for the first matching cell
Set firstcell = Cells.Find(what:="", searchformat:=True)

'if nothing was found, then exit
If firstcell Is Nothing Then
MsgBox "No matching cells found"
Exit Sub
End If

MsgBox "First cell is column: " & firstcell.Column & " row: " &
firstcell.Row

'initialize all cells
'Set allcells = firstcell
'Set foundcell = firstcell

'loop until the first cell is found again
'Do
' Set foundcell = Cells.FindNext(after:=foundcell)
' Set allcells = Union(foundcell, allcells)
' If foundcell.Address = firstcell.Address Then Exit Do
'Loop

'select the found cells and inform the user
'allcells.Select
'MsgBox "Matching cells found: " & allcells.Count

End Sub

I'd appreciate any input.

Thanks.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print cell borders with special 'skin' DavieM Excel Discussion (Misc queries) 0 March 25th 06 10:52 PM
click & drag not working Teresa Excel Discussion (Misc queries) 2 February 25th 06 01:52 AM
amount of working days per month Nigel Excel Discussion (Misc queries) 2 November 29th 05 10:41 AM
Working days left in the month compared to previous months qwopzxnm Excel Worksheet Functions 8 October 24th 05 08:00 PM
Using angled column headings and borders Lisa H Excel Discussion (Misc queries) 3 July 5th 05 04:30 PM


All times are GMT +1. The time now is 07:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"