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
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