I have data I generate from db query that outputs as a .xls file. See attached example.
I'd like to write a macro that will select the data block, name it "data", then use that named range to generate a pivot table.
The data in the "data" range will vary by the number of rows with each unique db query that I run.
I've tried recording a macro using relative references as follows, but that always seems to create a defined range
ActiveWorkbook.Names.Add Name:="data", RefersToR1C1:="=QRESULT!R1C1:R19C8"
How do write a macro that will select A1 through (xlLastCell) and name it "data"?