问题描述
我在 Excel VBA 中有此代码,用于检查某些记录的日期并检查它是否在我们要查找的日期范围内。这段代码上周似乎运行良好,但现在突然跳过记录。我发现,如果我要逐步完成编码,它会获取所有记录,但如果让它运行,它似乎会跳过记录。谁能帮忙解释一下原因。我对 VBA 相当陌生,我相信有些人会对编码感到畏缩,但它是我所知道的,并且在我的最后期限内工作。欢迎在解释正在发生的事情和避免这种情况的可能解决方案方面提供任何帮助。
MaxDate = ReportDate + 2
MinDate = ReportDate - 6
Set DatesEntryRange = Range("A2:A" & LastRowArray(2))
Datarange.AutoFilter Field:=1,Criteria1:=Array( "A","R","S"),Operator:=xlFilterValues
Datarange.AutoFilter Field:=9,Criteria1:= "Company Name"
Datarange.AutoFilter Field:=19,Criteria1:=Array( "Closed","Completed","Draft","Implementation In Progress","Pending","Planning In Progress","Request For Authorization","Request For Change","Scheduled","Scheduled For Approval","Scheduled For Review"),Operator:= xlFilterValues
Datarange.AutoFilter Field:=15,Criteria1:= "=Emergency",Operator:=xlOr,Criteria2:="=Expedited"
For Each DateEntry In DatesEntryRange.SpecialCells(xlCellTypeVisible)
If ErrorOccurance <> True Then
DateEntry.Select
Else
ErrorOccurance = False
GoTo NextCriteria1
End If
Select Case Cells(DateEntry.Row,"A").Value
Case "R"
If Cells(DateEntry.Row,"B").Value >= MinDate And Cells(DateEntry.Row,"B").Value < MaxDate Then
Cells(DateEntry.Row,"M").Interior.Color = RGB(RED,GREEN,BLUE)
ElseIf Cells(DateEntry.Row,"C").Value >= MinDate And Cells(DateEntry.Row,"C").Value < MaxDate Then
Cells(DateEntry.Row,"B").Value < MinDate And Cells(DateEntry.Row,"C").Value >= MaxDate Then
Cells(DateEntry.Row,BLUE)
Else
End If
Case "S"
If Cells(DateEntry.Row,"D").Value >= MinDate And Cells(DateEntry.Row,"D").Value < MaxDate Then
Cells(DateEntry.Row,"E").Value >= MinDate And Cells(DateEntry.Row,"E").Value < MaxDate Then
Cells(DateEntry.Row,"D").Value < MinDate And Cells(DateEntry.Row,"E").Value >= MaxDate Then
Cells(DateEntry.Row,BLUE)
Else
End If
Case "A"
If Cells(DateEntry.Row,"F").Value >= MinDate And Cells(DateEntry.Row,"F").Value < MaxDate Then
Cells(DateEntry.Row,"G").Value >= MinDate And Cells(DateEntry.Row,"G").Value < MaxDate Then
Cells(DateEntry.Row,"F").Value < MinDate And Cells(DateEntry.Row,"G").Value >= MaxDate Then
Cells(DateEntry.Row,BLUE)
Else
End If
Case Else
GoTo NextCriteria1
End Select
Next
reportdate 是一个日期变量,B 到 H 列都是日期。 LastRowArray 是一个整数数组,用于保存我生成的每个报告的最后一个单元格行。希望这里有人可以帮助解释为什么会跳过。
编辑:根据评论进行了一些更改。 Excel 无法找到数据或跳过数据的问题仍然存在。提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)