Free Support Forum -

How to paste and shift


I am trying to cut column D from a report and pasted it into column A

but I don't want to copy on top of colum A and loose it contents instead I want to shift column A to the right (to column B) and make room for column D

this is the commands I use:

SourceRange = wb.Worksheets("S1").Cells.CreateRange(0, 3, 50, 1)

destinationRange = wb.Worksheets("S1").Cells.CreateRange(0, 0, 50, 1)


In VBA there is the following command to do that: Selection.Insert Shift:=xlToRight

How can I do the shift right when inserting?

I look into PasteOptions of copy but no luck

Appreciate any help



I think you may try to use InsertRange() method or InsertColumn method accordingly first with your desired ShiftType option before copying the actual range.

Cells cells = range.Worksheet.Cells;
CellArea ca = new CellArea();
ca.StartRow = range.FirstRow;
ca.EndRow = ________;
ca.StartColumn = range.FirstColumn + range.ColumnCount;
ca.EndColumn = ________;
cells.InsertRange(ca, range.ColumnCount, ShiftType.Right, true);

Thanks for your response,

I was thinking that since aspose don't run vba macros it will be usefull for aspose cells to have a tool that converts VBA into aspose code


Aspose.Cells and VBA work on two different platforms, Aspose.Cells run on .NET framework and is actually build-up with a compiled language. The runtime engine of Aspose.Cells is .NET framework, while VBA is not a compiled language but a scripting language and its runtime environment is Ms-Office products.

So, it is highly unlikely that VBA code could be converted to Aspose.Cells code. But we will look into it further and see how such a thing could be achieved in future.