I have a UDF which gets a range of data and trims off x number of rows from the top (row headers).
I call this to load the data range into a variant variable as an array.
I use this function in this way on all worksheets and it works fine every time, however on 1 particular worksheet it throws an 'overflow' error and I don't know why.
I call the function like this:
Dim vTableArray As Variant
vTableArray = Get_Data_Range(Invoices", "A11", 2)
The Function is:
Function Get_Data_Range(sWorksheetName As String, sDataRange As String, iResizeOffset As Long) As Range
Set Get_Data_Range = Sheets(sWorksheetName).Range(sDataRange).CurrentRegion
Set Get_Data_Range = Get_Data_Range.Offset(iResizeOffset, 0).Resize(Get_Data_Range.Rows.Count - iResizeOffset, Get_Data_Range.Columns.Count)
End Function
When I debug the code, the error is thrown on the 'End Function' line of the UDF.
The range of data has 4925 rows and 59 columns. There are no errors in the data range.
Any help fixing this error appreciated.
Get_Data_Rangeis a normal function.