Hey there,
I'm writing an app that automatically creates a PivotTable.
I've got everything working, except that I want the PivotTables to all appear on the same sheet. Often, users will be performing actions that cause the pivottables' row count to go up and down. I've been asked to make the PivotTables have a 2-row buffer between them. I just need a way to detect if a PivotTable has overlapped another. I've got the code working that moves them up and down by row and column number, or by a difference (i.e. movePivotTableDownBy(2).).
Ideally, there would be an Excel Overlap function that would tell my how much the overlap was so I could move the remaining tables to where they need to be.
As this sheet evolves, I'd like to take into account having more than three PivotTables. Right now I'm at three.
So it would look something like this, I'd think:
Any ideas on the data structure for that? I've thought of some kind of variant dictionary, but I'm having a hard time seeing beyond a linear iteration. I'm thinking some kind of hash table, but the problem remains - what do I do to detect if there is a "table collision" without iterating through each entry in a collection, array, etc. and then back through it with each new entry. Some kind of insertion sort on the tops and iteration through the bottoms maybe? Even that seems too complicated.
Anyone got anything?
I'm writing an app that automatically creates a PivotTable.
I've got everything working, except that I want the PivotTables to all appear on the same sheet. Often, users will be performing actions that cause the pivottables' row count to go up and down. I've been asked to make the PivotTables have a 2-row buffer between them. I just need a way to detect if a PivotTable has overlapped another. I've got the code working that moves them up and down by row and column number, or by a difference (i.e. movePivotTableDownBy(2).).
Ideally, there would be an Excel Overlap function that would tell my how much the overlap was so I could move the remaining tables to where they need to be.
As this sheet evolves, I'd like to take into account having more than three PivotTables. Right now I'm at three.
So it would look something like this, I'd think:
Code:
For each pt in pivottables
get the top and the bottom
is there already (a table with bottom>pt.top) OR (a table with top<pt.bottom) <---- THIS IS WHAT I NEED
if so, move pt.(top or bottom) +- (the table with bottom/top) +- 2
Next x
Anyone got anything?