I am trying to create a macro in Excel 2016 that auto hides columns based on a string contained in a different cell. Right now, the Range R1:GJU1 is a formula that populates an X with an IF formula.
This is my code:
Sub Hide_Columns_Containing_Value()
Dim c As Range
For Each c In Range("R1:GJU1").Cells
If c.Value = "X" Then
c.EntireColumn.Hidden = False
End If
Next c
End Sub
I get this error:
Run-time error '13':
Type mismatch
Any help is appreciated!