General discussion
June 14, 2004 at 03:42 AM
mail

Copy cell content to another worksheet

by mail . Updated 22 years, 3 months ago

I need to enter data into the first worksheet in Excel and then select data from thre of the cells on the same row and add them to a new line in a second sheet in the same workbook.

eg – on first sheet I enter Name into A1, Age into B1, Postcode into C1.

I want to automatically add Name(A1) and Postcode(C1) to worksheet 2 in the first available row which should be row 1.

The next time I add data into first worksheet it will do the same but will add it to row 2 on sheet 2 and so on.

I have tried the code below, but can only get it to work for one cell.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> “$A$1” Then Exit Sub
‘ Sheet2 and Sheet3 intentionally updated separately
With Worksheets(“Sheet2”)
.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value _
= Target.Value
End With
With Worksheets(“Sheet3”)
.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Value _
= Target.Value
End With
End Sub

Any help appreciated.

This discussion is locked

All Comments