I have a bunch of workbooks with specific strings in the first row. So, for example I, say I have “Dog”, “Cat”, “Squirrel”, and “Fish” in rows A – D. I would like to have a macro that searches for the values ‘Dog’ and ‘Squirrel’, and hide the columns, and then subsequently set the width of “Cat” and “Fish” to a value of 11.
I cannot just use column numbers because they are not consistent across all my workbooks. Thanks for your help.
Sub HideColumn1()
If Range("B4").Value = 0 Then
Columns("H").EntireColumn.Hidden = True
Else
Columns("H").EntireColumn.Hidden = False
End If
End Sub
Change Range(“A1:D1”) to your desired range or something more dynamic: