Genheebles
New Member
- Joined
- Aug 23, 2021
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
I am hoping someone can assist me with this question. I have attempted to construct code to attach to a sheet in my excel workbook based on information I have gleaned from internet searches and forums .
What I am trying to achieve is for the sheet to automatically place a copy of a row from an entry sheet across to various other sheets in the workbook dependent on the cell text of column E. Ideally, I would like it to also leave a copy on the entry sheet.
The data is being entered into a sheet called 'Form'. The column into which the dependent text is being entered into is Column E. The dependent text is the same as the names of the other sheets in the workbook and these are represented within the following coding which I have attached to the 'Form Sheet'.
I want the formula to copy and paste the row from the 'Form' Sheet into the sheet of its same name positioned on the next available row. The row commences from column A.
Please don't laugh at my attempt..... I would be grateful for any assistance with where I have gone wrong with this.
Thanks
Genheebles
What I am trying to achieve is for the sheet to automatically place a copy of a row from an entry sheet across to various other sheets in the workbook dependent on the cell text of column E. Ideally, I would like it to also leave a copy on the entry sheet.
The data is being entered into a sheet called 'Form'. The column into which the dependent text is being entered into is Column E. The dependent text is the same as the names of the other sheets in the workbook and these are represented within the following coding which I have attached to the 'Form Sheet'.
I want the formula to copy and paste the row from the 'Form' Sheet into the sheet of its same name positioned on the next available row. The row commences from column A.
Please don't laugh at my attempt..... I would be grateful for any assistance with where I have gone wrong with this.
Thanks
Genheebles
VBA Code:
Private Sub Worksheet_MoveRow()
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Noble Park Office").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Noble Park Office" Then
Rows(Target.Row).Copy Destination:=Sheets("Noble Park Office").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Morwell Office").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Morwell Office" Then
Rows(Target.Row).Copy Destination:=Sheets("Morwell Office").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("East").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "East" Then
Rows(Target.Row).Copy Destination:=Sheets("East").Rows(Lastrow)
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Fadden").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Fadden" Then
Rows(Target.Row).Copy Destination:=Sheets("Fadden").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Harmer").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Harmer" Then
Rows(Target.Row).Copy Destination:=Sheets("Harmer").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Lightwood").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Lightwood" Then
Rows(Target.Row).Copy Destination:=Sheets("Lightwood").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Manchester").Cells(Rows.Count, "A").End(xlUp).Row + 1
Noble Par
If Target.Value = "Manchester" Then
Rows(Target.Row).Copy Destination:=Sheets("Manchester").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Princes").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Princes" Then
Rows(Target.Row).Copy Destination:=Sheets("Princes").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Chestnut").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Chestnut" Then
Rows(Target.Row).Copy Destination:=Sheets("Chestnut").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Comans").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Comans" Then
Rows(Target.Row).Copy Destination:=Sheets("Comans").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Drevermann").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Drevermann" Then
Rows(Target.Row).Copy Destination:=Sheets("Drevermann").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Lansdowne").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Lansdowne" Then
Rows(Target.Row).Copy Destination:=Sheets("Lansdowne").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Wy Yung").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Wy Yung" Then
Rows(Target.Row).Copy Destination:=Sheets("Wy Yung").Rows(Lastrow)
Rows(Target.Row).Delete
If Not Intersect(Target, Range("E:E")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Dim Lastrow As Long
Lastrow = Sheets("Goals").Cells(Rows.Count, "A").End(xlUp).Row + 1
If Target.Value = "Goals" Then
Rows(Target.Row).Copy Destination:=Sheets("Goals").Rows(Lastrow)
Rows(Target.Row).Delete
End If
End Sub