I have a sheet where I have a custom formula that is used for a graphical schedule on an Output sheet in excel. The function outputs the Date that is closest to the "MilestoneDate" input, but also places a physical marker/shape in the correct location on the sheet containing the schedule. I am having an issue with the line highlighted below in bold text (ONLY when there is a code break before this line); I get Excel VBA Error 424 "Object Required". If I do not have any breaks before this line, the function works fine.
I only can get XLOOKUP to work when MilestoneDate and TempOut are set as RANGE data type. Graph_Dates shows its output like this Graph_Dates Snapshot, which maybe(?) is part of the problem, but I don't get why if I do not watch before this problematic line the function behaves normally. I put it I have made a grave mistake somewhere that I am not seeing.
I do have some global variables at the top of the module:
TIA
I only can get XLOOKUP to work when MilestoneDate and TempOut are set as RANGE data type. Graph_Dates shows its output like this Graph_Dates Snapshot, which maybe(?) is part of the problem, but I don't get why if I do not watch before this problematic line the function behaves normally. I put it I have made a grave mistake somewhere that I am not seeing.
Rich (BB code):
Function Milestone(WBS As String, MilestoneDate As Range, ShowMarker As Range, TaskID As Long, Grph_Dates As Range, Grph_UIDs As Range, Watch_TaskColors As Range) As Variant
Milestone = "" 'Default Output
'Define Task Table (For Marker Generation)
Dim TTbl As ListObject
Dim Ind_Tsk As Long
Set TTbl = DataSheet.ListObjects("DataTable_Tasks")
Ind_Tsk = TTbl.ListColumns("Task").Index
'Define Variables for Date & Cell Targeting
Dim TempOut As Range 'Temporary storage of function output
Dim UID As String 'Unique Identifer for Row search
Dim col As Long 'column # for shape location
Dim row As Long 'row # for shape location
Dim Trgt As Range 'Target Cell for shape location
'Do Stuff
On Error GoTo skip
If WBS <> "" And MilestoneDate <> "" And ShowMarker.Value = True Then
With WorksheetFunction
Set TempOut = .XLookup(MilestoneDate, Grph_Dates, Grph_Dates, , 1) 'Find relevant date on graph for location {{{Excel VBA Error 424 when in debug}}}
If Not (IsEmpty(TempOut)) And Err = 0 Then 'If no error (date found) - Find Cell Address
Milestone = TempOut
'Unique ID for finding correct Graph Row to Assign Marker:
UID = WBS & "_" & .XLookup(TaskID, _
TTbl.ListColumns(1).DataBodyRange, _
TTbl.ListColumns(Ind_Tsk).DataBodyRange, _
, 0)
col = .Match(TempOut, Grph_Dates, 0) + 8 'Cell Column #
row = .Match(UID, Grph_UIDs, 0) + 3 'Cell Row #
Set Trgt = OutputSheet.Cells(row, col) 'Set Target Cell
'Call DrawMilestone(WBS, TaskID, ShowMarker, Trgt, TTbl)
Else
GoTo DMS
End If
End With
Else
DMS: If WBS <> "" Then Call DeleteMilestone(WBS, ShowMarker, TTbl)
End If
skip:
Call InvalidMilestone
'Call EnableWorkbook
I do have some global variables at the top of the module:
VBA Code:
Option Explicit
Global TempCalcCode As Long
TIA
Last edited by a moderator: