In a sub I've made in VBA, which is executed everytime the worksheet changes, the sub calls a function to determine if the user has deleted or changed something they shouldn't have. The function returns a boolean value to tell the sub if such a critical value has been deleted/edited. This way, the sub knows not to continue executing code.
However, whenever the code executes, VBA returns a Compile Error: Expected array
error for the calling of the criticalDataIntact()
function, despite there being no arrays used.
Here's my relevant code,
Private Sub Worksheet_Change(ByVal target As Range)
Worksheets(CONFIG).usedRange 'Refresh UsedRange
Dim criticalDataIntact As Boolean: criticalDataIntact = criticalDataIntact()
If Not criticalDataIntact Then
Exit Sub
End If
'Irrelevant code
End Sub
Private Function criticalDataIntact() As Boolean
Dim criticalDataIntact As Boolean: criticalDataIntact = True
Set warnWorkloadCell = ThisWorkbook.cell(CONFIG, WARNING_WORKLOAD, 0, 0)
Set dangerWorkloadCell = ThisWorkbook.cell(CONFIG, DANGER_WORKLOAD, 0, 0)
Dim table3Exists As Boolean: table3Exists = tableExists("Table3")
If warnWorkloadCell = Null Or dangerWorkloadCell = Null Or table3Exists = False Then
criticalDataIntact = False
End If
End Function
The cell
function outputs an error message via MsgBox
and returns Null
if it couldn't find a cell with a specific value in it within a specific worksheet.
Any ideas?