I've been trying for hours to do a macro that selects a raw data dump. I'm doing it like this:
Range("A1").Select 'Start at A1
Range(Selection, Selection.End(xlDown)).Select 'Go all the way down
Range(Selection, Selection.End(xlToRight)).Select 'Go all the way to the rgt
It works for different size data dumps thanks to xlDown
and xlToRight
. I guess this is far from optimal, though.
Now, I need to format that selection as a table to generate a pivot table.
How can I store that selection into a variable or a Variant and then use it within other code to format is as table?
As if I had VAR0 and VAR1 and then:
ActiveSheet.ListObjects.Add(xlSrcRange, Range(VAR0:VAR1), , xlYes).Name
= _"Table1"
I'm just learning VBA and using the macro recorder and am using some data to play with. I'd really appreciate some pointers! :)
I'm using Excel 2016.
Thanks!