Sub Hide_MyColumns()
Dim rPL, rDD
Set c = Sheets("blad1").Rows(4) 'in this row are your headers
my_hidden_headers = Array("name 1", "name 5", "name 7", "name8") 'array with all the headernames, that need to be hidden
For Each My_Header In my_hidden_headers 'loop through all wanted hidden headers
r = Application.Match(My_Header, c, 0) 'check if it excists !!!
If IsNumeric(r) Then c.Cells(1, r).EntireColumn.Hidden = True 'found = hide
Next
my_cf_headers = Array("Predisposed Location", "Due Date") 'array with all the headernames for CF
i = 0
For Each My_Header In my_cf_headers 'loop through all wanted hidden headers
i = i + 1 'pointer to know who is who
r = Application.Match(My_Header, c, 0) 'check if it excists !!!
If IsNumeric(r) Then
If i = 1 Then rPL = r Else rDD = r 'the 1st is Predis... and the 2nd match is Due Date
End If
Next
If IsNumeric(rPL) And IsNumeric(rDD) Then 'both columns found
Application.Goto Cells(1, rPL) 'goto column predisposed
With Union(Columns(rPL), Columns(rDD)) 'these 2 columns
.Cells.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:="=" & Cells(1, rPL).Address(0, 1) & "=""Y""" 'formula
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior 'setup
.PatternColorIndex = xlAutomatic
.Color = 5296274
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
End If
End Sub