Hello everyone,
I am having a hard time figuring out how to deal with a too zealous characteristic of Excel…
I am programming a macro that is basically just an advanced insertion : instead of just copying and inserting a range of cells, I want to allow the user to modify a certain number of values, add or remove rows etc... before inserting it back to the worksheet.
In order to do this, I insert the rows one by one while modifying what should be changed.
The problem with this solution it that it messes my formulas quite a bit.
For instance :
- If the row I am selecting (let's call it n) has a cell (for exemple A:n) whichs formula is refering to the following cell (A:n+1). It inserts it without a problem.
- Then, I insert the second row (n+1) of my selection, which is the one supposedly refered to by the cell A:n.
But since this is considered by Excel like a different insertion, when I insert my n+1th row, the formula in the A:nth cell is automatically changed so that it will refer to the row that was its n+1th at the time it was inserted - which is now n+2.
This functionnality that would be very useful in other situations is a real problem for me as my "special insertion" should keep the formulas well-formed like in a normal insertion.
What should I change so that it will work the way I wish it to ? Any ideas ?
My very first idea was to create a "virtual" range with my special insertion and then to insert it in the worksheet but I found no information anywhere on how to create these kinds of virtual ranges, which is why I came up with this not-so-satisfying one by one rows insertion.
Do you know a way to implement this instead ?
Thank you for reading,
Marie
I am having a hard time figuring out how to deal with a too zealous characteristic of Excel…
I am programming a macro that is basically just an advanced insertion : instead of just copying and inserting a range of cells, I want to allow the user to modify a certain number of values, add or remove rows etc... before inserting it back to the worksheet.
In order to do this, I insert the rows one by one while modifying what should be changed.
The problem with this solution it that it messes my formulas quite a bit.
For instance :
- If the row I am selecting (let's call it n) has a cell (for exemple A:n) whichs formula is refering to the following cell (A:n+1). It inserts it without a problem.
- Then, I insert the second row (n+1) of my selection, which is the one supposedly refered to by the cell A:n.
But since this is considered by Excel like a different insertion, when I insert my n+1th row, the formula in the A:nth cell is automatically changed so that it will refer to the row that was its n+1th at the time it was inserted - which is now n+2.
This functionnality that would be very useful in other situations is a real problem for me as my "special insertion" should keep the formulas well-formed like in a normal insertion.
What should I change so that it will work the way I wish it to ? Any ideas ?
My very first idea was to create a "virtual" range with my special insertion and then to insert it in the worksheet but I found no information anywhere on how to create these kinds of virtual ranges, which is why I came up with this not-so-satisfying one by one rows insertion.
Do you know a way to implement this instead ?
Thank you for reading,
Marie