1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

I'm trying to hide columns in excel when no conditional highlighting is present in the column

Discussion in 'Ask an Excel Question' started by bts1969, Apr 20, 2017.

  1. bts1969

    bts1969 New Member

    Messages:
    2
    I'm trying to hide columns in Excel when NO conditional highlighting (yellow color cell fill) is present in the column and unhide them if there is any cell in the column with yellow color cell fill. This VBA here is doing the reverse of what I need:

    Option Explicit
    Sub show_hide_columns_color()
    Dim cell As Range
    Dim button_color As Long

    For Each cell In Range("H2:J18") 'Change range to suit
    If cell.Interior.Color = 65535 Then
    If Columns(cell.Column).EntireColumn.Hidden Then
    Columns(cell.Column).EntireColumn.Hidden = False
    Else
    Columns(cell.Column).EntireColumn.Hidden = True
    End If
    End If
    Next
    End Sub
  2. ashokkumarkolla

    ashokkumarkolla Member

    Messages:
    57
    @bts1969

    Code (vb):

    Option Explicit
    Sub show_hide_columns_color()
    Dim cell As Range
    Dim button_color As Long

    For Each cell In Range("H2:J18") 'Change range to suit
    If Not cell.Interior.Color = 65535 Then
    If Columns(cell.Column).EntireColumn.Hidden Then
    Columns(cell.Column).EntireColumn.Hidden = False
    Else
    Columns(cell.Column).EntireColumn.Hidden = True
    End If
    End If
    Next
    End Sub
     
    hope this may work as intended.
    Thomas Kuriakose likes this.
  3. bts1969

    bts1969 New Member

    Messages:
    2
    ashokkumarkolla,
    Thank you! You made my day with your help!!
    Bryan

Share This Page