xlCellTypeSameFormatConditions

  • Thread starter Irada Shamilova
  • Start date
I

Irada Shamilova

Hi everyone!

How do I use the SpecialCells(xlCellTypeSameFormatConditions) method.
can't make it understand what format I'm looking for.
:confused:
I want to select all cells in a sheet that is in blue & italic. Coul
anyone please give me a samle code for this method.

Thanks in advance
Irad
 
R

Rob Bovey

Irada Shamilova said:
How do I use the SpecialCells(xlCellTypeSameFormatConditions) method. I
can't make it understand what format I'm looking for.
:confused:
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 *
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top