Hello,
I am trying to copy a formula I created in cell “K3” of my spreadsheet down ten rows. The formula in cell K3 is simply “$F3-$E3”.
So for example after the program runs it should have the following formulas -
Cell(K4) - "$F4-$E4"
Cell(K5) - "$F5-$E5
Cell(K6) - “$F6-$E6”, etc.
But instead it reads the following:
Cell(K4) - "$F6-$E6"
Cell(K5) - "$F7-$E7
Cell(K6) - “$F8-$E8”, etc.
In other words it skipped two rows. Below is the code I used. Do you know why? How can I fix this?
Thanks for any help you can provide.
R/
Dim Cells As Cell
Dim cells1 As Cells = oAsposeExcelWorkSheet.Cells
Cells = cells1(“K3”)
Cells.Formula = “=$F3-$E3”
Dim range1 As Range
Dim range2 As Range
cells1 = oAsposeExcelWorkSheet.Cells
range1 = cells1.CreateRange(2, 10, 10, 1)
range2 = cells1.CreateRange(3, 10, 10, 1)
range2.Copy(range1)
It’s a problem of copying overlapped ranges.
Please try the attached fix.
SORRY I DONT GET WAT U TALKIN bout’
HELLO,
I dont theres away to fix the problem that you are going through.
Thanks
Justavian
@justavian,
Aspose.Cells has replaced Aspose.Excel that is no more under active development now. You can not only work with all the features which were earlier supported by Aspose.Excel but also use the latest features available in different versions of MS Excel using Aspose.Cells. Copying a range with functions can be achieved using the following simple code:
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
Cells cells = worksheet.Cells;
cells["K3"].Formula = "=$F3-$E3";
Range range1 = cells.CreateRange(2, 10, 1, 1);
Range range2 = cells.CreateRange(3, 10, 10, 1);
range2.Copy(range1);
workbook.Save("output.xlsx");
For more information on working with ranges, refer to the following documents:
A free trial version is available here for testing the product features:
Aspose.Cells for .NET (Latest Version)
Here is a runnable solution to test the product features with the help of hundreds of ready to run examples.