As I am working with large csv files, I decided to load them into VBA memory instead of loading in my spreadsheet to make it quicker and lighter.
So I have a function CSVtoArray that read through my CSV and gives me an array.
Then if I still want to see my data in excel I just write {=(CSVtoArray(my_csv_path)} in my s/s.
But since the size of my csv changes over time, I wanted to write a function called AutoRange that would automatically fit the display area in my spreadsheet according to the size of my range.
So this is what I wrote but it's not working, it does nothing, only the cell in which I am writing the formula is filled.
Function AutoRange(my_array As Variant)
Dim nb_rows, nb_cols As Integer
Dim current_cell, target_range As Range
nb_rows = UBound(my_array, 1)
nb_cols = UBound(my_array, 2)
Set current_cell = Selection
current_cell.Resize(nb_rows, nb_cols).FormulaArray = current_cell.Formula
AutoRange = Selection
End Function
Thanks in advance guys.