PDA

View Full Version : [SOLVED] Error: Application-defined or object-defined when trying to hide row



mongoose
02-04-2020, 09:41 AM
I am trying to hide rows in a table based on certain criteria. I have the code working to find the cells and now I am trying to hide the other rows but when I do I get the following error: "Run-time error: '1004': Application-defined or object-defined error"
Here is my code:



'Intiansiate objects and setup variables
Dim tbl As ListObject
Dim c As Range
Dim colStartDate As Range
Dim FoundDate As Date
'Set object/variable values
Set tbl = ActiveWorkbook.Worksheets(1).ListObjects("Table1")

With tbl
'Search "Start Date" (Col2), top to bottom, searching for the first cell with a color index of 35 and the "End Date" (Col3) which has an index color of anything other than 35
Set colStartDate = .ListColumns("start date").DataBodyRange
For Each c In colStartDate.Cells
If c.Interior.ColorIndex = 35 And c.Offset(0, 1).Interior.ColorIndex <> 35 Then
FoundDate = c.Value
Exit For
End If
Next c

For Each c In colStartDate.Cells
If Not c.Hidden = True Then
If Not c.Value >= FoundDate Then
c.Hidden = True
End If
End If
Next c
End With

MsgBox FoundDate


It fails on:
If Not c.Hidden = True Then

mongoose
02-04-2020, 10:03 AM
Had to change to:
c.EntireRow.Hidden