excel - 在日期范围内查找日期VBA excel
问题描述
我对 VBA 非常陌生。在搜索日期范围内的日期后,我试图让 Excel 返回单元格地址。
我在 C 列中有一系列日期都设置为真实日期格式。
2018 年 1 月 12 日 2019 年 1 月 1 日 2019 年 1 月 2 日 ...
并在 D10 中单独约会。我想要一些 VBA 代码使用 D10 中的日期作为条件搜索 C 列,并返回结果的单元格地址。
在此先感谢您的帮助
编辑。
在 vba 的早些时候,我将 D10 定义为一个名为startingmonth 的日期变量。
这是我的代码。我只是使用 43435 作为文本作为测试,我想在这里使用起始月份(即 D10)但是当我用变量替换 43435 时,我收到错误 6 溢出。
Dim startingmonth As Date
startingmonth = Excel.Application.WorksheetFunction.EoMonth(ActiveCell.Offset(-2, 0).Value2, -1) + 1
Dim rgFound As Range
Set rgFound = Range("C:C").Find("43435")
MsgBox rgFound.Address
当前解决方法(来自活动单元格 D12)
ActiveCell.Offset(1, -1).Select
If ActiveCell.Value = startingmonth Then
MsgBox ActiveCell.Address
Else
GoTo Searchloop
End If
Searchloop:
ActiveCell.Offset(1, 0).Select
If ActiveCell.Value = startingmonth Then
MsgBox ActiveCell.Address
Else
GoTo Searchloop
End If
解决方案
推荐阅读
- python - 如何将变量关键字参数传递给 Python 中的函数?
- machine-learning - MIT 深度流量挑战中的奖励函数?
- android - 在多个活动中处理 oauth 意图
- android - 如何在键盘顶部显示视图?
- ios - 类型“PageViewController”不符合协议“UIPageViewControllerDataSource”
- r - 使用 R dygraphs 绘制小标题
- html - 在 HTML/CSS 中对齐两个 div
- c# - 获取 enumerable 中不存在其属性的对象
- c++ - QTableView::scrollTo 在模型重置后并经过一些延迟后立即
- typo3-7.6.x - 口语 URL,从口语 URL 中排除不起作用