I have a table with a column of form control check boxes on each row that I want a user to be able to select from and then have those selected rows be the only ones visible in another table (on another sheet).
So example Table 1:
Let's say I check boxes 1 and 3, so I'd want only two columns, corresponding to A and C, to be visible. Example Table 2:
Been trying to salvage together some code but not having any success (I'm a VBA noob, if this can be done without it that would be great, but I don't want to use filters it needs to be really user-friendly).
Essentially I'm trying to start by hiding all columns in Table 2 (manually have TRUE for the first and last, as those are the title and summary ones), then check each column if that cell is TRUE and if so, unhide it. The row with the TRUE values is row 8, and I have 33 total columns. Right now I'm getting a syntax error on first line, I tried to do this as a module but same issue. The Button is on Sheet 1 along with the check boxes, if that matters (the check boxes and TRUE links work). Thanks!
So example Table 1:
A1 | A2 | A3 | Check Box 1 |
B1 | B2 | B3 | Check Box 2 |
C1 | C2 | C3 | Check Box 3 |
D1 | D2 | D3 | Check Box 4 |
E1 | E2 | E3 | Check Box 5 |
Let's say I check boxes 1 and 3, so I'd want only two columns, corresponding to A and C, to be visible. Example Table 2:
TRUE | TRUE | TRUE | TRUE |
Title text | Title | Title | Summary formula |
Title text | Value from A1 | Value from C1 | Summary formula |
Title text | Value from A3 | Value from C3 | Summary formula |
Been trying to salvage together some code but not having any success (I'm a VBA noob, if this can be done without it that would be great, but I don't want to use filters it needs to be really user-friendly).
VBA Code:
Private Sub CommandButton1_Click()
Worksheets("Sheet 2").Columns.Hidden = True
Dim c As Integer
c = 1
For c = 1 To 33
If Worksheets("Sheet2").Cells(8,c).Value = "TRUE"
Worksheets("Sheet2").Columns(c).Hidden = False
End If
End With
Next c
End Sub
Essentially I'm trying to start by hiding all columns in Table 2 (manually have TRUE for the first and last, as those are the title and summary ones), then check each column if that cell is TRUE and if so, unhide it. The row with the TRUE values is row 8, and I have 33 total columns. Right now I'm getting a syntax error on first line, I tried to do this as a module but same issue. The Button is on Sheet 1 along with the check boxes, if that matters (the check boxes and TRUE links work). Thanks!
Last edited: