I have this code which reads data into an array.
For some reason this works:
Function TotalCost(col As Integer) As Double
Dim pricedata As Variant
Dim maxrows as Integer
maxrows = Worksheets(DATASHEET).Cells(Worksheets(DATASHEET).Rows.Count, col).End(xlUp).row
pricedata = Range(Cells(1, col)...