Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Based on data in previous column - sum of values in next column | Excel Worksheet Functions | |||
Shortcut to select column with data in previous column | Excel Discussion (Misc queries) | |||
Display column when previous column contains data | Excel Programming | |||
Copying a formula in a blank column as far as data in previous column | Excel Programming | |||
Macro that will autofill a column with data, up to the last row of data in previous c | Excel Programming |