This is a migrated thread and some comments may be shown as answers.

copy and paste cell in code

1 Answer 148 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 07 Mar 2016, 05:39 AM

Hi,

  I want to be able to grammatically copy a range of cells down several rows and have the formula's update automatically.  

I can get to the cells i want to copy and their formulas with code like

 

                            var dataSheet = sheetKendo.sheetByName("sheet1");
                            var sourceRange= dataSheet.range("A1");
                            var val = rowCountRange.value();
                            var formula = rowCountRange.formula(); // =Len(B1) + 2

How could I copy A1 to A2 and have the resulting formula in A2 =Len(B2)+2 in code, eg the same way as you drag down the black cross when doing this manually in the ui. 

 I know I could do it manually by setting the formula of A2 manually but it would mean I would have to parse and change the formula from A1.

 

Thanks for any help 

 

 


1 Answer, 1 is accepted

Sort by
0
Neil
Top achievements
Rank 1
answered on 07 Mar 2016, 08:53 AM

I worked it out, the following code will copy the range down 

                            sheetKendo._workbook.execute({
                                command: 'AutoFillCommand',
                                options: {
                                    operatingRange: dataSheet.range("i4:l6"),
                                    origin: dataSheet.range("i3:l3")
                                }
                            });

Tags
Spreadsheet
Asked by
Neil
Top achievements
Rank 1
Answers by
Neil
Top achievements
Rank 1
Share this question
or