rjplante
Well-known Member
- Joined
- Oct 31, 2008
- Messages
- 563
- Office Version
- 365
- Platform
- Windows
I have a table with 14 column in it. The columns are grouped into pairs 3 and 4, 5 and 6, etc. I have row 4 set aside with a check cell in the second column for each pair, that will either have a YES or a NO in it. A user can compare data in what ever column has a YES in the second column. I would like to have a macro that will hide all the rows without data in the first column of the set (3, 5, 7, 9, 11, 13, and 15) for each column with a YES in the second column. If multiple columns are selected, rows for the first set of columns (3-4) may not have any data in them, but there is data in the second set of columns (5-6), so the row should be displayed and vice versa. If a single set of columns is selected (3-4) then all rows without data in column 3 will be hidden. And this would apply for any single set of columns selected. If there is no data in the first column for a particular row, then hide that row.
My code below is to hide all of the columns that have a NO in the second set of columns. I just need to figure out how to apply the filter on the rows and across multiple columns. I am currently at a loss as to where to begin.
My code below is to hide all of the columns that have a NO in the second set of columns. I just need to figure out how to apply the filter on the rows and across multiple columns. I am currently at a loss as to where to begin.
VBA Code:
Dim n As Integer
Sheets("Data Table").Range("C4").Select
n = 3
For n = 3 To 16
If Cells(4, n).Value = "NO" Then
Columns(n).EntireColumn.Hidden = True
Columns(n - 1).EntireColumn.Hidden = True
End If
Next n