I currently have a VBA macro that turns a regular data extract into a table. In the macro I have defined a range which is large enough to exceed the number of rows typically extracted.
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$AG$20000"), , xlYes).Name _
= "Table1"
My macro then does some other transformation/addition of formulas etc to the table, and the table is then presented via PowerBI.
I want to delete the excess rows in the table - which varies for each extract.
In the example below - which has recorded the desired sequence of steps, there are only 186 rows.
Range("Table1[[#Headers],[Client Id]]").Select
Selection.End(xlDown).Select
Range("A187").Select
Range(Selection, Selection.End(xlDown)).Select
Rows("187:20000").Select
Selection.Delete Shift:=xlUp
I want to store the range ("A187") as a variable I then want to insert the stored variable in the selection 187:20000
Alternatively, if I could do a variabilised selection of the range I want to turn into a table, that would work too.
Any help would be appreciated.