I am writing up a Macro to be used in my worksheet and I was hoping that you could please help me figure out why it’s not working exactly how I intended.
I have a worksheet that pulls information from several other worksheets to provide a score and any discrepancies observed. I am trying to make all rows that have a “N/A” (text) listed in the column D to automatically hide when the Macro runs.
Here is what I have so far:
Sub HideRows()
On Error Resume Next
With Range("A9:D142")
.EntireRow.Hidden = False
For i = 1 To .Rows.Count
If WorksheetFunction.Sum(.Rows(i)) = "N/A" Then
.Rows(i).EntireRow.Hidden = True
End If
Next i
End With
End Sub
Instead of hiding only the rows with “N/A” in Column D, it hides all the rows.
Can you please let me know what I am doing wrong?
Thank you for your help in advance!
I have a worksheet that pulls information from several other worksheets to provide a score and any discrepancies observed. I am trying to make all rows that have a “N/A” (text) listed in the column D to automatically hide when the Macro runs.
Here is what I have so far:
Sub HideRows()
On Error Resume Next
With Range("A9:D142")
.EntireRow.Hidden = False
For i = 1 To .Rows.Count
If WorksheetFunction.Sum(.Rows(i)) = "N/A" Then
.Rows(i).EntireRow.Hidden = True
End If
Next i
End With
End Sub
Instead of hiding only the rows with “N/A” in Column D, it hides all the rows.
Can you please let me know what I am doing wrong?
Thank you for your help in advance!