Red over White
Board Regular
- Joined
- Jul 16, 2011
- Messages
- 123
- Office Version
- 365
- Platform
- MacOS
I am trying to hide rows where the cells value in each of the cells is ErrNA for the cells in columns B to F, and then repeat the exercise over a number of rows. If any cell within B to F is not ErrNA (it will be a number) then I don't want to hide the row.
The program doesn't like the red line, and possibly not the following line. The program works if I replace RowVar(j) with the actual row number, but I would prefer not to have to write out this line numerous times to get the desired effect.
Where am I going wrong?
Sub Graphic2022()
Application.ScreenUpdating = False
Sheets("Graphic").Activate
Rows("2:100").EntireRow.Hidden = False
Dim j As Integer
Dim RowVar As Variant
RowVar = Array("2", "3", "4", "5", "6", "7", "8", "9")
For j = 0 To 7
If Cells(RowVar(j), 2).Value = CVErr(xlErrNA) And Cells(RowVar(j), 3).Value = CVErr(xlErrNA) And Cells(RowVar(j), 4).Value = CVErr(xlErrNA) And Cells(RowVar(j), 5).Value = CVErr(xlErrNA) And Cells(RowVar(j), 6).Value = CVErr(xlErrNA) Then
Rows(RowVar(j) & ":" & RowVar(j)).EntireRow.Hidden = True
End If
Next j
End sub
The program doesn't like the red line, and possibly not the following line. The program works if I replace RowVar(j) with the actual row number, but I would prefer not to have to write out this line numerous times to get the desired effect.
Where am I going wrong?
Sub Graphic2022()
Application.ScreenUpdating = False
Sheets("Graphic").Activate
Rows("2:100").EntireRow.Hidden = False
Dim j As Integer
Dim RowVar As Variant
RowVar = Array("2", "3", "4", "5", "6", "7", "8", "9")
For j = 0 To 7
If Cells(RowVar(j), 2).Value = CVErr(xlErrNA) And Cells(RowVar(j), 3).Value = CVErr(xlErrNA) And Cells(RowVar(j), 4).Value = CVErr(xlErrNA) And Cells(RowVar(j), 5).Value = CVErr(xlErrNA) And Cells(RowVar(j), 6).Value = CVErr(xlErrNA) Then
Rows(RowVar(j) & ":" & RowVar(j)).EntireRow.Hidden = True
End If
Next j
End sub