Hi all,
i've found this macro that will hide columns in a range based on a cell value. But how would the code be written to hide every OTHER column that doesn't contain that value in the row?
so as example, if i want to hide every other column EXCEPT the ones with X
thanks
i've found this macro that will hide columns in a range based on a cell value. But how would the code be written to hide every OTHER column that doesn't contain that value in the row?
so as example, if i want to hide every other column EXCEPT the ones with X
Code:
Sub Hide_Columns_Containing_Value()
'Description: This macro will loop through a row and
'hide the column if the cell in row 1 of the column
'has the value of X.
'Author: Jon Acampora, Excel Campus
'Source:
Dim c As Range
For Each c In Range("A1:G1").Cells
If c.Value = "X" Then
c.EntireColumn.Hidden = True
'You can change the property above to False
'to unhide the columns.
End If
Next c
End Sub
thanks