hlhelterbrand
New Member
- Joined
- Dec 9, 2016
- Messages
- 6
Hello,
So until now I have only viewed answers on this site, but it has helped me sooo many times! I could not find an answer to the question below, so hopeful one of you awesome people can help!
So I have few versions of what I have tried, but I think that a command button would work best. I am trying to use the name in column 2 to determine if the data in that row should be hidden or not. Ideally I would like the button to hide all lines that contain the name, then unhide all of those rows when clicked again.
Below is some code that I came up with, but it isn't working
Private Sub CommandButton1_Click()
BeginRow = 1
EndRow = 250
ChkCol = 2
If CommandButton1.Caption = "Hide Information" Then
ElseIf Cells(RowCnt, ChkCol).Value = "John Smith" Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
CommandButton1.Caption = "Show Information" And Cells(RowCnt, ChkCol).Value = "John Smith"
Else
Range("D:G, AF:AG, AJ:AO").EntireRow.Hidden = False
CommandButton1.Caption = "Hide Information"
End If
Next
End If
Next
End Sub
So until now I have only viewed answers on this site, but it has helped me sooo many times! I could not find an answer to the question below, so hopeful one of you awesome people can help!
So I have few versions of what I have tried, but I think that a command button would work best. I am trying to use the name in column 2 to determine if the data in that row should be hidden or not. Ideally I would like the button to hide all lines that contain the name, then unhide all of those rows when clicked again.
Below is some code that I came up with, but it isn't working

Private Sub CommandButton1_Click()
BeginRow = 1
EndRow = 250
ChkCol = 2
If CommandButton1.Caption = "Hide Information" Then
ElseIf Cells(RowCnt, ChkCol).Value = "John Smith" Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
CommandButton1.Caption = "Show Information" And Cells(RowCnt, ChkCol).Value = "John Smith"
Else
Range("D:G, AF:AG, AJ:AO").EntireRow.Hidden = False
CommandButton1.Caption = "Hide Information"
End If
Next
End If
Next
End Sub