![]() |
Copy a row from one sheet to another and not all columns copy
I am brand new at this, sorry if I am not clear. I have a production
sheet in excel. What I want is on another sheet have the rows copy automatically when a date is put in column D on the production sheet, to the next available row on the other sheet, but I do not need all the columns. Out of 29 Columns in the production sheet I only need 6 of them copied to the new sheet. Example on the production sheet I have columns A-AC, when I add a date to column D in the production sheet I want only column D, F, H, N, T, and U to copy on the other sheet. When the information is on the other sheet it also auto sorts by column D of the new sheet. If anyone can help I would appreciate it. Thank You. |
Copy a row from one sheet to another and not all columns copy
Put this code behind your production sheet, name the target sheet "Record"
or change the code as shown below. You need to record that the row has already been copied, so I add a 1 into column AD for the row in question. The code tests if the column D entry is a Date, if not the copy does not happen. Only changes in column D from row 2 upwards, trigger this code. Row 1 on the 'Record' sheet is for headings, place these in this sheet before you run the code for the first time. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Column = 4 And Target.Row 1 Then If IsDate(Target.Value) And Cells(Target.Row, 30) < 1 Then ' transfer parts of this row to Record sheet With Sheets("Record") ' <<< change the name of the target sheet here ' determine last row on record sheet Dim xlr As Long xlr = .Cells(.Rows.Count, 1).End(xlUp).Row ' copy selected cells to record from production (change for other columns etc,) .Cells(xlr + 1, 1) = Cells(Target.Row, "D") .Cells(xlr + 1, 2) = Cells(Target.Row, "F") .Cells(xlr + 1, 3) = Cells(Target.Row, "H") .Cells(xlr + 1, 4) = Cells(Target.Row, "N") .Cells(xlr + 1, 5) = Cells(Target.Row, "T") .Cells(xlr + 1, 6) = Cells(Target.Row, "V") ' record that row data has been transferred Cells(Target.Row, 30) = 1 ' sort the record sheet by date .Range("A2:F" & xlr + 1).Sort Key1:=.Range("A2"), Order1:=xlAscending End With End If End If End Sub -- Cheers Nigel "Peaches" wrote in message ups.com... I am brand new at this, sorry if I am not clear. I have a production sheet in excel. What I want is on another sheet have the rows copy automatically when a date is put in column D on the production sheet, to the next available row on the other sheet, but I do not need all the columns. Out of 29 Columns in the production sheet I only need 6 of them copied to the new sheet. Example on the production sheet I have columns A-AC, when I add a date to column D in the production sheet I want only column D, F, H, N, T, and U to copy on the other sheet. When the information is on the other sheet it also auto sorts by column D of the new sheet. If anyone can help I would appreciate it. Thank You. |
Copy a row from one sheet to another and not all columns copy
Nigel,
Thank you for your help. Being brand new it did take a while for me, but the formula works great. Thank, Peaches |
All times are GMT +1. The time now is 04:53 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com