Sub HideCols()
Dim x As Long
Dim rng As Range
Const HeaderRow As Long = 1
Application.ScreenUpdating = False
Cells(HeaderRow, 6).Resize(, 22).EntireColumn.Hidden = False
For x = 6 To 27
If Cells(HeaderRow, x).Value <> Cells(28, 4).Value Then
If rng Is Nothing Then
Set rng = Cells(HeaderRow, x)
Else
Set rng = Union(rng, Cells(HeaderRow, x))
End If
End If
Next x
rng.EntireColumn.Hidden = True
Application.ScreenUpdating = True
Set rng = Nothing
End Sub
You are running the code from the same raw data starting point and not after the macro has been run once or more?
Cells(HeaderRow, 6).Resize(, 22).EntireColumn.Hidden = False
Cells(HeaderRow, 5).Resize(, 24).EntireColumn.Hidden = False