2

When I insert a row in Excel charts and other shapes does not move with their cells.
Let's say I have a chart at A5:D:10, then i insert a row below 2nd row, so now chart should be at A6:D:11, but the chart stays there and hides the 5th row.

I design a template containing a chart and a shape, then at runtime I am supplying data to the chart and changing a few properties of the shapes. Now my chart contains some data in its first 5 rows and I insert a row after the 2nd row then everything should go one row down, but this is not happening.

At design time I have checked if the chart's property to move and size with cells is set to true. Yet this is not happening at runtime programmatically. Although at design time inserting rows have no issues.

Please help me to solve my problem
Thanks.

3 Answers 3

4

I had this problem, and setting any of the graph's properties made no difference. I traced my problem, it was due to having multiple sheets in my workbook. I was inserting cells in a number of sheets but only ever having the first sheet active.

If I added currentsheet.Activate(); before I inserted cells the graph moved as you'd had expected it to.

0

I had the same problem and managed to fix it by unlocking the chart(s).

1
  • 1
    what do you mean by unlocking charts, and how do you do it programmatically.
    – j4m4l
    Aug 10, 2012 at 22:32
0

i solved it with workaround, incase somebody comes looking -
chart and shapes are still not moving, but now i am assigning TopLeftCell property of chart and shape at runtime and forcing them to move, although now i have overhead of keeping its location.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.