G
Guest
I'm trying to automate excel from c#. One of the things I need to do is to
copy/paste/insert rows in excel via c# code.
I tried to do the following:
1) Select a row in excel (a12 to k12)
2) Insert a row.
3) copy contents of a12 to k12.
4) Paste these contents to new row.
The "Record Macro" function returns the following code:
Range("A13:K13).Select
Selection.Insert shift:=xlDown
Range("A14:k14).Select
Selection.Copy
Range("A13:k13").Select
ActiveSheet.Paste
I tried to translate part of the code above to the following:
oRange = oSheet.get_Range("A13", "K13");
oRange.Select();
oExcel.ActiveCell.Insert(-4121);
I needed the code to insert a new row in the specified range. But instead,
it just inserts a row for cell A13.
What am i doing wrong?
Mansi
copy/paste/insert rows in excel via c# code.
I tried to do the following:
1) Select a row in excel (a12 to k12)
2) Insert a row.
3) copy contents of a12 to k12.
4) Paste these contents to new row.
The "Record Macro" function returns the following code:
Range("A13:K13).Select
Selection.Insert shift:=xlDown
Range("A14:k14).Select
Selection.Copy
Range("A13:k13").Select
ActiveSheet.Paste
I tried to translate part of the code above to the following:
oRange = oSheet.get_Range("A13", "K13");
oRange.Select();
oExcel.ActiveCell.Insert(-4121);
I needed the code to insert a new row in the specified range. But instead,
it just inserts a row for cell A13.
What am i doing wrong?
Mansi