Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying one column with hidden/filtered rows to another colum Rechie Excel Discussion (Misc queries) 2 September 14th 09 06:28 PM
Transpose a text string while copying adjacent column data to new willc Excel Worksheet Functions 5 May 31st 07 08:20 PM
When data match, copy adjacent value to adjacent column slimbim Excel Worksheet Functions 2 November 8th 06 08:41 PM
summing values from adjacent column with refrence from adjacent column Pivotrend Excel Discussion (Misc queries) 6 March 4th 06 11:24 AM
copying non-adjacent cells hke[_2_] Excel Programming 1 October 15th 03 01:21 PM


All times are GMT +1. The time now is 02:11 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"