Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a number of spreadsheets where I need to go through and insert two
columns at 26 places in each spreadsheet. I'm trying to make this a little faster by writing a VBA macro that I can run with keystrokes. What I tried to do was tell it select the column that I am currently in and insert two columns to the right of that column. The problem I am having is that it is inserting the columns to the left instead of the right. I can't figure out why. Here's the code I've written: With ActiveCell .EntireColumn.Select End With Selection.Insert Shift:=xlToRight Selection.Insert Shift:=xlToRight Any help would be appreciated. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
try this but you really don't have to use the active cell.
Sub inserttwocolums() x = ActiveCell.Row y = ActiveCell.Column Range(Cells(x, y), Cells(x, y + 1)).EntireColumn.Insert End Sub -- Don Guillett SalesAid Software "FinChase" wrote in message ... I have a number of spreadsheets where I need to go through and insert two columns at 26 places in each spreadsheet. I'm trying to make this a little faster by writing a VBA macro that I can run with keystrokes. What I tried to do was tell it select the column that I am currently in and insert two columns to the right of that column. The problem I am having is that it is inserting the columns to the left instead of the right. I can't figure out why. Here's the code I've written: With ActiveCell .EntireColumn.Select End With Selection.Insert Shift:=xlToRight Selection.Insert Shift:=xlToRight Any help would be appreciated. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Fin Chase.
-- --- Regards, Norman "FinChase" wrote in message ... I have a number of spreadsheets where I need to go through and insert two columns at 26 places in each spreadsheet. I'm trying to make this a little faster by writing a VBA macro that I can run with keystrokes. What I tried to do was tell it select the column that I am currently in and insert two columns to the right of that column. The problem I am having is that it is inserting the columns to the left instead of the right. I can't figure out why. Here's the code I've written: With ActiveCell .EntireColumn.Select End With Selection.Insert Shift:=xlToRight Selection.Insert Shift:=xlToRight Any help would be appreciated. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Either select the cell to the right either manually or via code.
activecell.offset(0,1).resize(1,2).entirecolumn.in sert FinChase wrote: I have a number of spreadsheets where I need to go through and insert two columns at 26 places in each spreadsheet. I'm trying to make this a little faster by writing a VBA macro that I can run with keystrokes. What I tried to do was tell it select the column that I am currently in and insert two columns to the right of that column. The problem I am having is that it is inserting the columns to the left instead of the right. I can't figure out why. Here's the code I've written: With ActiveCell .EntireColumn.Select End With Selection.Insert Shift:=xlToRight Selection.Insert Shift:=xlToRight Any help would be appreciated. -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi FinChase,
Try: ActiveCell(1, 2).Resize(1, 2).EntireColumn.Insert If the 26 positions can be identified by a given rule, then your macro could be adapred to insert all the required columns on each worksheet. --- Regards, Norman "FinChase" wrote in message ... I have a number of spreadsheets where I need to go through and insert two columns at 26 places in each spreadsheet. I'm trying to make this a little faster by writing a VBA macro that I can run with keystrokes. What I tried to do was tell it select the column that I am currently in and insert two columns to the right of that column. The problem I am having is that it is inserting the columns to the left instead of the right. I can't figure out why. Here's the code I've written: With ActiveCell .EntireColumn.Select End With Selection.Insert Shift:=xlToRight Selection.Insert Shift:=xlToRight Any help would be appreciated. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Is it possible to insert a column into the first row programmatically using C#. I tried using wsSales.Columns.EntireColumn.Insert(Excel.XlInsert ShiftDirection.xlShiftToRight); but it does not work. I even tried using a range and then inserting a column before that range but that didn't work either. Please help! -- rkappini ------------------------------------------------------------------------ rkappini's Profile: http://www.excelforum.com/member.php...o&userid=31216 View this thread: http://www.excelforum.com/showthread...hreadid=496406 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Inserting columns | Excel Discussion (Misc queries) | |||
VB EXCEL INSERTING COLUMNS | Excel Discussion (Misc queries) | |||
inserting new columns | Excel Discussion (Misc queries) | |||
Inserting columns into a row | Excel Discussion (Misc queries) | |||
Inserting Columns | Excel Worksheet Functions |