Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
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
searching 2 values from 2 cells Steve Excel Discussion (Misc queries) 5 January 25th 10 07:45 PM
Searching for Linked Cells jordanpcpre Excel Discussion (Misc queries) 4 December 3rd 08 01:08 AM
Searching a cells contents? SteW Excel Worksheet Functions 2 August 21st 07 11:48 AM
Searching for string in other cells Ruatha Excel Worksheet Functions 3 June 9th 06 10:42 PM
Anyone know how to format cells as yes/no boolean logic? JethroUK© New Users to Excel 3 July 19th 05 05:41 AM


All times are GMT +1. The time now is 11:58 PM.

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"