範囲内の現在の日付を検索し、見つかったセルを返す関数があります。そのセルの位置を使用して、サブルーチン内のオフセットを計算しようとしています。ただし、マクロを実行するobjected required
と、エラーが発生します。関数とサブルーチンは次のとおりです。
Function findCurrentDate() As Range
Dim needle As Date
Dim rng As Range
needle = CLng(Date)
Dim haystack As Range
Dim search As Range
Set haystack = Range("B3:B86")
Set search = haystack.Find(needle, After:=haystack(1), _
LookIn:=xlValues, Lookat:=xlWhole, _
SearchOrder:=xlNext, MatchByte:=True)
End Function
Sub showFutureWeeklyHours()
Dim wkday_row_offset As Integer
Dim search As Range
Set search = findCurrentDate()
Set wkday_row_offset = search.Row
...
End Sub
これは完全なサブルーチンではありませんが、エラーを再現するには十分です。日付のリストはセルに保存されますB3:B86