Setting a formular to cell result adds additional rows to the activeSheet

Posted by: hpmx on 8 September 2017, 1:44 pm EST

  • Posted 8 September 2017, 1:44 pm EST

    <p>Hi,</p><p>testing then rowcount resulst in: <br></p><p><font face="courier new,courier">?me.fpsTargetValues.ActiveSheet.Rows.count<br>8 </font></p><p>after executing the following statement: <br></p><p><font face="courier new,courier">Me.fpsTargetValues.ActiveSheet.Cells(7, 3).Formula="SUM($D$1:$D$6)" </font></p><p>testing the rowcount results in:</p><p><font face="courier new,courier"> ?me.fpsTargetValues.ActiveSheet.Rows.count<br>10</font></p><p>and i get an "index out of bounds" message!</p><p> </p><p>Any hint why? </p><p>Regards hpm</p><p> </p><p> </p>
  • Replied 8 September 2017, 1:44 pm EST

    <P>hpm,</P>
    <P>Formula assignment (and recalculation) should not affect the row count.  I can not reproduce the issue with the provided information.  My guess is that you have something else occuring in the application that is causing the adding of the additional rows.  Do you have any event handlers that could be adding the rows (e.g. Changed event on sheet data model is raised as cell values are updated during a recalculation)?  Is you sheet bound to a data source that is dynmically changing dimensions?  Could you provide us with an application (or code snippet) that reproduces the problem?</P>
  • Replied 8 September 2017, 1:44 pm EST

    <p>Hi, </p><p>I looked once more on our source code and found the following:</p><p>(actual row size is 6)</p><p>/code </p><p>with Me.fpsTargetValues.ActiveSheet                        </p><p>.Rows.Add(idx, 2)<br> .Rows(idx).BackColor = Color.Black<br>  .Rows(idx).Height = 2<br> .Cells(idx + 1, 0).Value = "SUMME"<br> .Cells(idx + 1, 3).Formula = "SUM($D$1:$D$" & idx & ")"<br> intPoints = CInt(.Cells(idx + 1, 3).Value)<br> .Cells(idx + 1, 5).Formula = "SUM($F$1:$F$" & idx & ")"<br> intPointsPROG = CInt(.Cells(idx + 1, 5).Value)</p><p>....<br>/end code</p><p>Is it allowed to add rows to a sheet, which is bound to a datasource  by saying " .rows.add(...) or have we to do this in the underlying datasource itsself?</p><p> Furthermor is allowed to add formulars to sheet bounded to a datasource?</p><p>Thanks in advance </p><p>hpm</p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p>
  • Replied 8 September 2017, 1:44 pm EST

    <P>hpm,</P>
    <P>It is legal to call Rows.Add on a bound Spread. However, this will add the row and it's data to the bound DataSource, which may not be the result you are looking for. In this case, you need to use the AddUnboundRows method to add rows to the Spread that are not bound to the DataSource.</P>
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels