I am trying use VBA to create a pivot table. The data is on a worksheet "ALL OUTSTANDING REMITS". I am sending the pivot table to a created worksheet "PreSummary". The data will always have the same number of columns, but the number of rows will vary.
I recorded a macro to get the core code, however I would like to use a variable range for the source data. I have found multiple options that I think should work, however nothing is working for me. Here is the code from the macro that works:
My most recent attempt is this:
I have checked and the code is highlighting the correct range and the name exists in the name manager with the correct cells. When I run the macro, it errors on that last section with:
"Run Time Error '1004' - This command requires at least two rows of source data. You cannot use the command on a selection in only one row..."
So I am either passing the name to the argument incorrectly, or setting the range incorrectly, or something. I know that is probably not the most elegant creation of the named range, and I am open to suggestions. I also tried this:
This also selected the correct range, but gave the same error.
Thanks for any help.