Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to paste data to a new column if previous column has data

Hello,

I have a range of data in column A. I want to be able to run a macro
and paste it into another column (C). Then later when i make a change
to the data in column A, i want to be able to paste it into the next
available column (in this particular example it would be column D).

Any help would be much appreciated.

Thanks
Neil

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Macro to paste data to a new column if previous column has data

Hi Neil,

Assuming that your data to be copied starts in row 1, you could use
something like the following:

Sub CopyToNextEmptyColumn()
Dim rngSource As Range
Dim rngDestination As Range

Set rngSource = Range("A1:A12")
Set rngDestination = Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1)

rngSource.Copy Destination:=rngDestination
End Sub

If there is an entry in B1 and nothing in the cells to the left of B1, the
above code will make the first copy in the C column and subsequent copies in
the next empty column.

John Green

"Neil" wrote in message
ups.com...
Hello,

I have a range of data in column A. I want to be able to run a macro
and paste it into another column (C). Then later when i make a change
to the data in column A, i want to be able to paste it into the next
available column (in this particular example it would be column D).

Any help would be much appreciated.

Thanks
Neil



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to paste data to a new column if previous column has data

On Feb 13, 2:03 pm, "John Green" <greenj@nospam wrote:
Hi Neil,

Assuming that your data to be copied starts in row 1, you could use
something like the following:

Sub CopyToNextEmptyColumn()
Dim rngSource As Range
Dim rngDestination As Range

Set rngSource = Range("A1:A12")
Set rngDestination = Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1)

rngSource.Copy Destination:=rngDestination
End Sub

If there is an entry in B1 and nothing in the cells to the left of B1, the
above code will make the first copy in the C column and subsequent copies in
the next empty column.

John Green

"Neil" wrote in message

ups.com...



Hello,


I have a range of data in column A. I want to be able to run a macro
and paste it into another column (C). Then later when i make a change
to the data in column A, i want to be able to paste it into the next
available column (in this particular example it would be column D).


Any help would be much appreciated.


Thanks
Neil- Hide quoted text -


- Show quoted text -


Thanks John - it works great.

Cheers
Neil

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to paste data to a new column if previous column has data

On Feb 13, 4:02 pm, "Neil" wrote:
On Feb 13, 2:03 pm, "John Green" <greenj@nospam wrote:





Hi Neil,


Assuming that your data to be copied starts in row 1, you could use
something like the following:


Sub CopyToNextEmptyColumn()
Dim rngSource As Range
Dim rngDestination As Range


Set rngSource = Range("A1:A12")
Set rngDestination = Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1)


rngSource.Copy Destination:=rngDestination
End Sub


If there is an entry in B1 and nothing in the cells to the left of B1, the
above code will make the first copy in the C column and subsequent copies in
the next empty column.


John Green


"Neil" wrote in message


oups.com...


Hello,


I have a range of data in column A. I want to be able to run a macro
and paste it into another column (C). Then later when i make a change
to the data in column A, i want to be able to paste it into the next
available column (in this particular example it would be column D).


Any help would be much appreciated.


Thanks
Neil- Hide quoted text -


- Show quoted text -


Thanks John - it works great.

Cheers
Neil- Hide quoted text -

- Show quoted text -


Hi John,

A further query.

Say i pasted data into columns C, D, E. i then find that i don't want
to keep the data in column D. How would i go about altering the above
code so that it finds the next available column as column D rather
than F.

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
Based on data in previous column - sum of values in next column Beena K Excel Worksheet Functions 1 April 7th 09 07:23 PM
Shortcut to select column with data in previous column TJAC Excel Discussion (Misc queries) 1 July 10th 07 06:12 PM
Display column when previous column contains data [email protected] Excel Programming 1 January 3rd 07 03:01 PM
Copying a formula in a blank column as far as data in previous column basildon Excel Programming 1 December 16th 05 03:32 PM
Macro that will autofill a column with data, up to the last row of data in previous c Max Velocity Excel Programming 4 November 27th 03 10:34 AM


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

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"