Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Searching for Boolean Cells
Hi,
I'm using the following statement to set an object equal to the boolean cells in a worksheet. After that I can colour them to identify their location. However if there are no such cells in the worksheet an error is generated. I could use resume next and clear the errors but a neater way would obviously be a test for the existence of boolean cells before the colouring loop is entered dim cellcollection as object Set cellCollection = Selection.SpecialCells(xlCellTypeConstants, xlLogical) For Each cell In cellCollection ActiveSheet.Cells(cell.Row, cell.Column).Interior.ColorIndex = booleanColour Next cell Suggestions...Thanks Chris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Searching for Boolean Cells
You don't need to rely on an error:
Sub Macro1() Dim cell As Range For Each cell In Selection If Application.IsLogical(cell.Value) Then cell.Interior.ColorIndex = 3 End If Next cell End Sub -- Gary''s Student "Chris Gorham" wrote: Hi, I'm using the following statement to set an object equal to the boolean cells in a worksheet. After that I can colour them to identify their location. However if there are no such cells in the worksheet an error is generated. I could use resume next and clear the errors but a neater way would obviously be a test for the existence of boolean cells before the colouring loop is entered dim cellcollection as object Set cellCollection = Selection.SpecialCells(xlCellTypeConstants, xlLogical) For Each cell In cellCollection ActiveSheet.Cells(cell.Row, cell.Column).Interior.ColorIndex = booleanColour Next cell Suggestions...Thanks Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
searching 2 values from 2 cells | Excel Discussion (Misc queries) | |||
Searching for Linked Cells | Excel Discussion (Misc queries) | |||
Searching a cells contents? | Excel Worksheet Functions | |||
Searching for string in other cells | Excel Worksheet Functions | |||
Anyone know how to format cells as yes/no boolean logic? | New Users to Excel |