ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert Column to the left in a list (https://www.excelbanter.com/excel-programming/412821-insert-column-left-list.html)

Shane

Insert Column to the left in a list
 
I am using lists to help with my data, and I want to be able to add a
new column when the month starts. So I want to add a column in the
list to the left of my total column. When I record my steps with the
Macro recorder it gives me this.

Selection.ListObject.ListColumns.Add (28) which always puts a new
column at the 28 position.

the other code of

ActiveCell.Offset(0, 1).EntireColumn.Insert

doesn't work with lists. I have named the range of the total row to
Total12 (because I am summing the most recent 12 months). Thanks for
your help.

Shane

JLGWhiz

Insert Column to the left in a list
 
Range("Total12").EntireColumn.Insert

Should insert new column and move the Total12 to the right.

"Shane" wrote:

I am using lists to help with my data, and I want to be able to add a
new column when the month starts. So I want to add a column in the
list to the left of my total column. When I record my steps with the
Macro recorder it gives me this.

Selection.ListObject.ListColumns.Add (28) which always puts a new
column at the 28 position.

the other code of

ActiveCell.Offset(0, 1).EntireColumn.Insert

doesn't work with lists. I have named the range of the total row to
Total12 (because I am summing the most recent 12 months). Thanks for
your help.

Shane


Shane

Insert Column to the left in a list
 
On Jun 19, 9:29*am, Shane wrote:
I am using lists to help with my data, and I want to be able to add a
new column when the month starts. So I want to add a column in the
list to the left of my total column. When I record my steps with the
Macro recorder it gives me this.

Selection.ListObject.ListColumns.Add (28) which always puts a new
column at the 28 position.

the other code of

ActiveCell.Offset(0, 1).EntireColumn.Insert

doesn't work with lists. I have named the range of the total row to
Total12 (because I am summing the most recent 12 months). Thanks for
your help.

Shane


Nevermind. I figured it out.

Thanks anyway

Don Guillett

Insert Column to the left in a list
 
Assumes a header row in row 1

Sub addcolumnbeforelastcolumn()
Columns(Cells(1, Columns.Count).End(xlToLeft).Column).Insert
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Shane" wrote in message
...
I am using lists to help with my data, and I want to be able to add a
new column when the month starts. So I want to add a column in the
list to the left of my total column. When I record my steps with the
Macro recorder it gives me this.

Selection.ListObject.ListColumns.Add (28) which always puts a new
column at the 28 position.

the other code of

ActiveCell.Offset(0, 1).EntireColumn.Insert

doesn't work with lists. I have named the range of the total row to
Total12 (because I am summing the most recent 12 months). Thanks for
your help.

Shane



Shane

Insert Column to the left in a list
 
On Jun 19, 9:45*am, JLGWhiz wrote:
Range("Total12").EntireColumn.Insert

Should insert new column and move the Total12 to the right.

"Shane" wrote:
I am using lists to help with my data, and I want to be able to add a
new column when the month starts. So I want to add a column in the
list to the left of my total column. When I record my steps with the
Macro recorder it gives me this.


Selection.ListObject.ListColumns.Add (28) which always puts a new
column at the 28 position.


the other code of


ActiveCell.Offset(0, 1).EntireColumn.Insert


doesn't work with lists. I have named the range of the total row to
Total12 (because I am summing the most recent 12 months). Thanks for
your help.


Shane


Thanks, it worked great.


All times are GMT +1. The time now is 05:11 AM.

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