Create a button in excell to hide a row based on value in a cell in corresponding column.

Anonymous
2016-02-24T09:29:48+00:00

I want to create a button to "Hide" or "unhide" entire row based on values in corresponding cell D.

I have data in in column A to H & row 1 to 103. I want to hide all rows if value in cell D is "Not Applicable". i.e.

row 1 should hide if D1="Not Applicable"  

row 3 should hide if D3="Not Applicable"  etc.

And additional button to unhide all hidden row which are hidden by above button.

I have attached a screenshot to provide better understanding. 

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2016-02-24T09:41:54+00:00

    Hi,

    To hide rows then put a button on your worksheet and attach the code below. To unhide the rows attach another button and change the TRUE in bold to FALSE and attach that code.

    Dim LastRow As Long, x As Long

    LastRow = Cells(Cells.Rows.Count, "D").End(xlUp).Row

    For x = 1 To LastRow

    If UCase(Cells(x, "D")) = "NOT APPLICABLE" Then

        Rows(x).Hidden = True

    End If

    Next

    0 comments No comments
  2. Anonymous
    2016-02-25T09:08:40+00:00

    Thank you very much Mike. It is working great.

    0 comments No comments