+ Reply to Thread
Results 1 to 8 of 8

code for hiding rows-(coloured)

  1. #1
    srinivasan
    Guest

    code for hiding rows-(coloured)

    Hell friends,

    I want to know whether it is possible to create a code which by invoking it
    to run should hide the rows which are highlighted by a particular colour.
    If so any one will help me by providing it.



  2. #2
    Bob Phillips
    Guest

    Re: code for hiding rows-(coloured)

    Try this

    Sub Test()
    Dim rw As Range

    For Each rw In ActiveSheet.UsedRange.Rows
    If rw.Interior.ColorIndex = 34 Then
    rw.Hidden = True
    End If
    Next rw

    End Sub



    --
    HTH

    Bob Phillips

    "srinivasan" <[email protected]> wrote in message
    news:[email protected]...
    > Hell friends,
    >
    > I want to know whether it is possible to create a code which by invoking

    it
    > to run should hide the rows which are highlighted by a particular

    colour.
    > If so any one will help me by providing it.
    >
    >




  3. #3
    srinivasan
    Guest

    Re: code for hiding rows-(coloured)


    Mr Bob,
    Thanks a lot. But as I am not familiar to VBA how it will work? Any colour
    to the cell background or font colour.If I change the colour is the code has
    to be changed


  4. #4
    Bob Phillips
    Guest

    Re: code for hiding rows-(coloured)

    We are talking cell colour here, testing the Colorindex.

    Do you want to check both cell colour and font colour? If so, what colours?

    --
    HTH

    Bob Phillips

    "srinivasan" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Mr Bob,
    > Thanks a lot. But as I am not familiar to VBA how it will work? Any colour
    > to the cell background or font colour.If I change the colour is the code

    has
    > to be changed
    >




  5. #5
    srinivasan
    Guest

    Re: code for hiding rows-(coloured)



    Hello,

    I want to use the cell colour with pale blue(not font colour). Expecting
    your kind response.

  6. #6
    Bob Phillips
    Guest

    Re: code for hiding rows-(coloured)

    Sub Test()
    Dim rw As Range

    For Each rw In ActiveSheet.UsedRange.Rows
    If rw.Interior.ColorIndex = 37 Then 'Pale blue
    rw.Hidden = True
    End If
    Next rw

    End Sub

    Go to the VB IDE (alt-F11), insert a code module (Insert>Module), and paste
    the code in.

    Then in excel Tools>Macro>Macros... and select Test and Run.

    --
    HTH

    Bob Phillips

    "srinivasan" <[email protected]> wrote in message
    news:[email protected]...
    >
    >
    > Hello,
    >
    > I want to use the cell colour with pale blue(not font colour). Expecting
    > your kind response.




  7. #7
    srinivasan
    Guest

    Re: code for hiding rows-(coloured)



    Thank a lot Mr Bob! It works nice. But if I want to change the color what
    should I do?

  8. #8
    Bob Phillips
    Guest

    Re: code for hiding rows-(coloured)

    Hi Srinivasan,

    You need to find the colorindex for a colour, and update it.

    This simple code returns all the colorindex values as the row number

    For i = 1 to 56
    Cells(i,"A").Value = i
    Cells(i,"B").Interior.Colorindex = i
    Next i

    --
    HTH

    Bob Phillips

    "srinivasan" <[email protected]> wrote in message
    news:[email protected]...
    >
    >
    > Thank a lot Mr Bob! It works nice. But if I want to change the color what
    > should I do?




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1