【发布时间】:2020-07-24 03:21:16
【问题描述】:
我有一个 Excel 作为时间线记录。 B 列包含一年中的日期,其右侧的列记录各种事件。
我想制作一个可以跳转到当前日期行的按钮。我尝试做的第一件事是找到一个包含特定日期的单元格。我从 B 列中的现有单元格中获取日期,然后返回查找它。但是Find 方法什么也不返回。
Sub gotoToday()
Dim LDate As Date
Dim dateCol As Range
Dim cell As Range
LDate = Range("b197").Value ' do get a valid date value here
Set dataCol = Range("B2:B365") ' b197 is inside the range
dataCol.Select
Set cell = Selection.Find(what:=LDate, after:=ActiveCell, LookIn:=xlFormulas, _
Lookat:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
cell.Select ' cell get Nothing here
End Sub
基本上我在关注This stackoverflow post。不知道我错过了什么,有人可以帮我吗?
【问题讨论】: