Reputation: 359
I have an Excel workbook where I have multiple number of sheets. I want to hide some of the columns in all the sheets where headers starting with a string "AUDIT_"
.
I am trying to find out a simple solution to hide these columns in all the sheets so that I don't need to go every sheet and click hide.
Can you please suggest me on this.
Upvotes: 0
Views: 2452
Reputation: 96753
Give this a try:
Sub ColumnHider()
Dim s As Worksheet, N As Long, i As Long
For Each s In Worksheets
s.Activate
N = Cells(1, Columns.Count).End(xlToLeft).Column
For i = 1 To N
If Left(Cells(1, i).Value, 6) = "AUDIT_" Then
Cells(1, i).EntireColumn.Hidden = True
End If
Next i
Next s
End Sub
Upvotes: 1