Consulting

Results 1 to 2 of 2

Thread: Font Color Cell

  1. #1

    Font Color Cell

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •