Copy entire row to another worksheet

Carl_London

New Member
Joined
Feb 28, 2023
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
I am new to excel and using macros so please be kind!

I wish to copy an entire row from one worksheet called "list" and copy that entire row to another worksheet called "logged". The copied row should go to the next available empty row in the "logged" worksheet and then clear the contents of that row from the original worksheet. I would like to be able to do the move by using a macro button.

Can anyone help please?

Thanks, Carl

This code works but not the way I want, in this version I have to enter an "l" in the coloumn A of the first worksheet, but I'd rather do it with one mouse click of a button:

Private Sub Worksheet_Change(ByVal Target As Range)

' Check to see only one cell updated If Target.CountLarge > 1 Then Exit Sub

' Check to see if entry is made in column B after row 5 and is set to "Yes" If Target.Column = 1 And Target.Row > 4 And Target.Value = "l" Then Application.EnableEvents = False ' Copy columns B to M to complete sheet in next available row Range(Cells(Target.Row, "B"), Cells(Target.Row, "N")).Copy Sheets("logged").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) ' Delete current row after copied Rows(Target.Row).ClearContents Application.EnableEvents = True
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
welcome to the forum, I think the way I would program that functionality is to put the code into the double click event and then trigger it only when doulbe clicking column A ( you could easily change the column)
Try this code in the worksheet code for the "list" workhseet:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
rowno = Target.Row
If Target.Column = 1 Then
  lastcol = Cells(rowno, Columns.Count).End(xlToLeft).Column
  inarr = Range(Cells(rowno, 1), Cells(rowno, lastcol))
  Range(Cells(rowno, 1), Cells(rowno, lastcol)) = ""
  
  With Worksheets("logged")
   lastrow = .Cells(Rows.Count, "A").End(xlUp).Row + 1
   .Range(.Cells(lastrow, 1), .Cells(lastrow, lastcol)) = inarr
   End With
End If
End Sub
Now just doulbe click on a a row in column A and check it copies across ok
 
Upvote 0
Hi,

Thank you for your help. Unfortunately it returned an error and did not copy the row across (although it did disappear from the list worksheet!)

1677627796164.png
 
Upvote 0
Oops, sorry that error was because I messed up with the name of the logged sheet. No error message now but it's only deleting from the first worksheet, not moving to the logged worksheet.
Thanks again for your help (and patience!)
 
Upvote 0
Try this small change in your original post.

**Quoted**
Check to see if entry is made in column B after row 5 and is set to "Yes" If Target.Column = 1 And Target.Row > 4 Then Application.EnableEvents = False ' Copy columns B to M to complete sheet in next available row Range(Cells(Target.Row, "B"), Cells(Target.Row, "N")).Copy Sheets("logged").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) ' Delete current row after copied Rows(Target.Row).ClearContents Application.EnableEvents = True
**Quoted**
 
Upvote 0
Try this small change in your original post.

**Quoted**
Check to see if entry is made in column B after row 5 and is set to "Yes" If Target.Column = 1 And Target.Row > 4 Then Application.EnableEvents = False ' Copy columns B to M to complete sheet in next available row Range(Cells(Target.Row, "B"), Cells(Target.Row, "N")).Copy Sheets("logged").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) ' Delete current row after copied Rows(Target.Row).ClearContents Application.EnableEvents = True
**Quoted**
I removed the And Target.Value = "I"
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top