InsertAndCopyRange to Right Shift a Cell

Is the "proper" way to implement:
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

to find an empty cell and copy it?  Something like:
 xls.InsertAndCopyRange(New FlexCel.Core.TXlsCellRange(100, 1, 100, 1), xlsRowNum + xlsShiftRow, xlsColNum, 1, FlexCel.Core.TFlxInsertMode.ShiftRangeRight)

This works, but I have to find an empty cell first.

Hi,

I am not 100% sure on what you want to do. If it is to just insert rows, use:

xls.InsertAndCopyRange(New FlexCel.Core.TXlsCellRange(1, 1, 1, 1), xlsRowNum + xlsShiftRow, xlsColNum, 1, FlexCel.Core.TFlxInsertMode.ShiftRangeRight, TRangeCopyMode.None)

Using TRangeCopy.None, you don't have to worry about an empty cell, nothing will be copied.

Now, if what you want is to mimic the "xlFormatFromLeftOrAbove, that is insert the cells by copying the format of the row above, you could use:

xls.InsertAndCopyRange(New FlexCel.Core.TXlsCellRange(xlsRowNum + xlsShiftRow - 1, 1, xlsRowNum + xlsShiftRow - 1, FlxConsts.Max_Columns + 1), xlsRowNum + xlsShiftRow, xlsColNum, 1, FlexCel.Core.TFlxInsertMode.ShiftRangeRight, TRangeCopyMode.Formats)

In general, if possible I would use the first way because it is faster. But the second should work too.

Ah, I missed the TRangeCopyMode argument.  Thanks!