Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programatically unhide columns based on cell color? 1

Status
Not open for further replies.

adrikev

Programmer
May 17, 2002
36
0
0
US
I have a range of columns that are currently hidden. I would like to unhide a column based on a cells color. Here is the code I have so far (it doesn't work).

Code:
    Range("R2:DQ2").Select
    For Each Item In Selection
        If Item.Font.ColorIndex = 35 Then
            With Item
                Columns(Item.Columns).Select
                Selection.EntireColumn.Hidden = False
            End With
        End If
    Next Item

Suggestions? Thoughts? --------------------------------
Fortius, Citius, nullis secundus
Strength, Speed, second to none
 
If it is the font color you are looking for try this.

Code:
Range("R2:DQ2").Select
    For Each Item In Selection
        If Item.Font.ColorIndex = 35 Then
            With Item
                Item.EntireColumn.Hidden = False
                'Columns(Item.Columns).Select
                'Selection.EntireColumn.Hidden = False
            End With
        End If
    Next

If it is the cell color you are looking for, try this

Code:
Range("R2:DQ2").Select
    For Each Item In Selection
        If Item.Interior.ColorIndex = 35 Then
            With Item
                Item.EntireColumn.Hidden = False
                'Columns(Item.Columns).Select
                'Selection.EntireColumn.Hidden = False
            End With
        End If
    Next

This worked in my test file, let us know if this works.

Dave
 
Super Dave,

Thanks for the help. The "Interior" property was tripping me up. Not to mention the column selection. --------------------------------
Fortius, Citius, nullis secundus
Strength, Speed, second to none
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top