Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a Value Down a Column for Every Value in An Adjacent Colum
I am trying to write a macro that does three things.
1. Inserts a column in front of a column. 2. Enters a value in the first row of the new empty column that is next to the first cell in the old column. 3. Copy the contents of the cell to every cell adjacent to the next column. So, imagine that Column A contains three rows of data: Football Basketball Baseball I want to insert a column in front of Column A. I then want to insert the value "2005" for every row based on how many rows are in column B. Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a Value Down a Column for Every Value in An Adjacent Colum
hi Charles.
Try something like this: Dim LastRow Range("A1").Select Selection.End(xlDown).Select LastRow = ActiveCell.Row Columns("A:A").Select Selection.Insert Shift:=xlToRight cells(1,1) = "2005" Selection.AutoFill Destination:=Range(cells(1,1),cells(LastRow,1)), Type:=xlFillDefault Miguel "Charles Allen" wrote: I am trying to write a macro that does three things. 1. Inserts a column in front of a column. 2. Enters a value in the first row of the new empty column that is next to the first cell in the old column. 3. Copy the contents of the cell to every cell adjacent to the next column. So, imagine that Column A contains three rows of data: Football Basketball Baseball I want to insert a column in front of Column A. I then want to insert the value "2005" for every row based on how many rows are in column B. Thank you. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a Value Down a Column for Every Value in An Adjacent C
hi again i forgot 1 thing:
Dim LastRow Range("A1").Select Selection.End(xlDown).Select LastRow = ActiveCell.Row Columns("A:A").Select Selection.Insert Shift:=xlToRight cells(1,1).select cells(1,1) = "2005" Selection.AutoFill Destination:=Range(cells(1,1),cells(LastRow,1)), Type:=xlFillDefault "Liedson31" wrote: hi Charles. Try something like this: Dim LastRow Range("A1").Select Selection.End(xlDown).Select LastRow = ActiveCell.Row Columns("A:A").Select Selection.Insert Shift:=xlToRight cells(1,1) = "2005" Selection.AutoFill Destination:=Range(cells(1,1),cells(LastRow,1)), Type:=xlFillDefault Miguel "Charles Allen" wrote: I am trying to write a macro that does three things. 1. Inserts a column in front of a column. 2. Enters a value in the first row of the new empty column that is next to the first cell in the old column. 3. Copy the contents of the cell to every cell adjacent to the next column. So, imagine that Column A contains three rows of data: Football Basketball Baseball I want to insert a column in front of Column A. I then want to insert the value "2005" for every row based on how many rows are in column B. Thank you. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Copying a Value Down a Column for Every Value in An Adjacent Colum
Thank you very much. Your assistance has proven very valuable.
"Charles Allen" wrote: I am trying to write a macro that does three things. 1. Inserts a column in front of a column. 2. Enters a value in the first row of the new empty column that is next to the first cell in the old column. 3. Copy the contents of the cell to every cell adjacent to the next column. So, imagine that Column A contains three rows of data: Football Basketball Baseball I want to insert a column in front of Column A. I then want to insert the value "2005" for every row based on how many rows are in column B. Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
copying one column with hidden/filtered rows to another colum | Excel Discussion (Misc queries) | |||
Transpose a text string while copying adjacent column data to new | Excel Worksheet Functions | |||
When data match, copy adjacent value to adjacent column | Excel Worksheet Functions | |||
summing values from adjacent column with refrence from adjacent column | Excel Discussion (Misc queries) | |||
copying non-adjacent cells | Excel Programming |