mercredi 29 juin 2016

If #REF! then hide certain rows

I have created 2 sheets, Sheet no. 1 shows the data nicely and the other imports the data. Therefore sheet no. 1 gets data from sheet no. 2. However sometimes there are no data in sheet no 2. This gives the cells in sheet 1 "#REF!". When this happens i need to hide certain rows in sheet 1.

So i imagine something like this

Sub HideCharts()

BeginRow = 132
EndRow = 138
ChkCol = 8

For RowCnt = BeginRow To EndRow
    If Cells(RowCnt, ChkCol).Value = 0 Then
        Cells(RowCnt, ChkCol).EntireRow.Hidden = True
    End If
Next RowCnt

        For RowCnt = BeginRow To EndRow
            If Cells(RowCnt, ChkCol).Value <> 0 Then
                Cells(RowCnt, ChkCol).EntireRow.Hidden = False
            End If
        Next RowCnt
End Sub 

However this only works if the data is 0 and i got no clue on how to catch the #REF! also this only hides the rows that contains the 0 value, but i need to catch certain rows like 130 to 140

So i thought, who else to turn to than Stack Overflow?

Aucun commentaire:

Enregistrer un commentaire