ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting a column using C# and Excel 2000 (https://www.excelbanter.com/excel-programming/352626-inserting-column-using-c-excel-2000-a.html)

rkappini[_3_]

Inserting a column using C# and Excel 2000
 

I need to programmatically insert a column in the first column of an
Excel sheet. I tried using the code
wsSheet.Columns.EntireColumn.Insert(Excel.XlInsert ShiftDirection.xlShiftToRight);

and I even tried creating a range and shifting the range to the right
and then inserting a column, but that didn't work either.

Am really in need of help here.... please let me know if there is some
code i can use. And for some reason
oWSheet.Columns(1).Insert
doesn't work either.


--
rkappini
------------------------------------------------------------------------
rkappini's Profile: http://www.excelforum.com/member.php...o&userid=31216
View this thread: http://www.excelforum.com/showthread...hreadid=509322


Nick Hodge

Inserting a column using C# and Excel 2000
 
I'm not going to be much help here, but to confirm in VBA you would use

Worksheets("Sheet1").Columns(1).Insert

Therefore as you have a reference to the worksheet object it should work. I
can only presume you should check the .NET side, imported namespace?
properly reference the worksheet object?

Do you get any build errors?

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
www.nickhodge.co.uk


"rkappini" wrote in
message ...

I need to programmatically insert a column in the first column of an
Excel sheet. I tried using the code
wsSheet.Columns.EntireColumn.Insert(Excel.XlInsert ShiftDirection.xlShiftToRight);

and I even tried creating a range and shifting the range to the right
and then inserting a column, but that didn't work either.

Am really in need of help here.... please let me know if there is some
code i can use. And for some reason
oWSheet.Columns(1).Insert
doesn't work either.


--
rkappini
------------------------------------------------------------------------
rkappini's Profile:
http://www.excelforum.com/member.php...o&userid=31216
View this thread: http://www.excelforum.com/showthread...hreadid=509322




rkappini[_4_]

Inserting a column using C# and Excel 2000
 

Thanks Nick. For some reason I couldn't access a column using
wsSheet.Columns(1)... that gave me an error. Anyways, I used a range
and inserted a column... am sure there's a much better way to do it but
this goes for now :-) Thanks!


--
rkappini
------------------------------------------------------------------------
rkappini's Profile: http://www.excelforum.com/member.php...o&userid=31216
View this thread: http://www.excelforum.com/showthread...hreadid=509322



All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com