ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding Columns in Excel 2007 (2003 Compatibility Mode) (https://www.excelbanter.com/excel-programming/396421-adding-columns-excel-2007-2003-compatibility-mode.html)

AndyJ

Adding Columns in Excel 2007 (2003 Compatibility Mode)
 
both Please advise,

I am trying to add columns as per the following code:

Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

When i check the worksheet, columns A and B have been selected,

If I run the following code:

Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

only Column C is selected.

Can anyone help?

Dave Peterson

Adding Columns in Excel 2007 (2003 Compatibility Mode)
 
I didn't start xl2007, but different versions of excel treat merged cells
differently.

Do you have any cells in A:B that are merged?

AndyJ wrote:

both Please advise,

I am trying to add columns as per the following code:

Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

When i check the worksheet, columns A and B have been selected,

If I run the following code:

Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

only Column C is selected.

Can anyone help?


--

Dave Peterson

AndyJ

Adding Columns in Excel 2007 (2003 Compatibility Mode)
 
Cheers Dave,

I didnt consider that!.

I have been writing in VB.NET and not VBA for the last couple of years and
have forgotten some simple checks.

Thanks for your help.


"Dave Peterson" wrote:

I didn't start xl2007, but different versions of excel treat merged cells
differently.

Do you have any cells in A:B that are merged?

AndyJ wrote:

both Please advise,

I am trying to add columns as per the following code:

Columns("B:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

When i check the worksheet, columns A and B have been selected,

If I run the following code:

Columns("C:C").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove

only Column C is selected.

Can anyone help?


--

Dave Peterson



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

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