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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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

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
How do I copy columns when part of formula has another sheet in it andrewwatkins Excel Discussion (Misc queries) 1 November 4th 07 11:59 PM
How do i copy rows to columns on separate sheet, and have them upd Gre Excel Worksheet Functions 2 November 23rd 06 05:36 PM
Macro to copy columns from 1st sheet to 2nd according to mapping-p Pawan Excel Programming 2 June 22nd 05 05:53 AM
Create copy of sheet using VB with columns in different order Bryan Excel Programming 1 May 4th 05 04:40 AM
macro to copy columns to sheet Es Excel Discussion (Misc queries) 1 March 7th 05 02:03 PM


All times are GMT +1. The time now is 07:12 PM.

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

About Us

"It's about Microsoft Excel"