PDA

View Full Version : Font Color Cell



teodormircea
08-08-2008, 06:59 AM
Hello
I made a little macro that make a hide on font color in a column but is stooping at the first blank cell. I don't know if is the best solution for that , maybe an auto filter is the best solution, so i don't make to do unhide every time i apply the macros .
Here is the code
Sub FILTER_FONTCOLOR()

'On g?le l'?cran
Application.ScreenUpdating = False

'D?claration des variables
Dim i As Long
Dim coll As Integer
Dim color As Integer
coll = InputBox(Prompt:="Choisir Colonne a filtrer")
color = InputBox(Prompt:="Choisir Couleur a filtrer")
'Code
i = 2 'En partant de la 2?me ligne, on peut conserver une ligne d'ent?te
While Not IsEmpty(Cells(i, coll))
If Not Cells(i, coll).Font.ColorIndex = color Then
Rows(i).EntireRow.Hidden = True
End If

i = i + 1
Wend

End Sub Thanks for you help

Bob Phillips
08-08-2008, 07:53 AM
Sub FILTER_FONTCOLOR()

'On g?le l'?cran
Application.ScreenUpdating = False

'D?claration des variables
Dim i As Long
Dim coll As Long
Dim LastRow As Long


Dim color As Integer
coll = InputBox(Prompt:="Choisir Colonne a filtrer")
color = InputBox(Prompt:="Choisir Couleur a filtrer")
'Code
LastRow = Cells(Rows.Count, coll).End(xlUp).Row
For i = 2 To LastRow 'En partant de la 2?me ligne, on peut conserver une ligne d'ent?te

If Not Cells(i, coll).Font.ColorIndex = color Then

Rows(i).Hidden = True
End If
Next i

End Sub