我正在尝试将一些代码集成到实时文件中。它正在我放入的测试文件中工作;但是当我尝试对实时数据运行它时,它在隐藏一行后就停止了。
没有错误或任何东西;就像它不会像预期的那样循环播放。我不确定这是什么。
这是代码
With tbl
'Search ColJ ("CNC Begins") for the first cell with a color index of 15 and the ColK ("CNC Ends") which has an index color of anything other than 15
Set colStartDate = .ListColumns("CNC Begins").DataBodyRange
For Each c In colStartDate.Cells
If c.Interior.ColorIndex = 15 And c.Offset(0, 1).Interior.ColorIndex <> 15 And IsDate(c.Value) And Not c.Offset(0, -9).Value = "C" Then
FoundDate = c.Value
Exit For
End If
Next c
For Each c In colStartDate.Cells
If Not c.EntireRow.Hidden = True Then
'Hide dates prior to colStartDate but not empty cells
If Not IsEmpty(c.Value) And IsDate(c.Value) Then
MsgBox c.Value & ">=" & FoundDate & " | Address " & c.Address
'Exit Sub
If Not c.Value >= FoundDate And IsDate(c.Value) And Not IsError(c.Value) Then
c.EntireRow.Hidden = True
End If
End If
End If
Next c
End With
ActiveSheet.Buttons(Application.Caller).Caption = "Show"