Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Print cell borders with special 'skin' | Excel Discussion (Misc queries) | |||
click & drag not working | Excel Discussion (Misc queries) | |||
amount of working days per month | Excel Discussion (Misc queries) | |||
Working days left in the month compared to previous months | Excel Worksheet Functions | |||
Using angled column headings and borders | Excel Discussion (Misc queries) |