View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rob Bovey Rob Bovey is offline
external usenet poster
 
Posts: 811
Default xlCellTypeSameFormatConditions

"Irada Shamilova" wrote in
message ...
How do I use the SpecialCells(xlCellTypeSameFormatConditions) method. I
can't make it understand what format I'm looking for.

I want to select all cells in a sheet that is in blue & italic. Could
anyone please give me a samle code for this method.


Hi Irada,

The xlCellTypeSameFormatConditions constant tells Excel that you want to
find all the cells with the same *condition format* as the currently
selected cell. It doesn't have anything to do with the formats that you
apply to the cell using the Format/Cells menu, for example.

The only way to do what you are trying to do is through brute force VBA
enumeration of all the cells in the used range of the active worksheet.
Here's one example of how it could be done:

Sub SelectBlueItalicFont()
Dim rngCell As Range
Dim rngAccumulate As Range
For Each rngCell In ActiveSheet.UsedRange
If rngCell.Font.Italic And (rngCell.Font.ColorIndex = 5) Then
If rngAccumulate Is Nothing Then
Set rngAccumulate = rngCell
Else
Set rngAccumulate = Union(rngAccumulate, rngCell)
End If
End If
Next rngCell
If Not rngAccumulate Is Nothing Then rngAccumulate.Select
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *