Help with setting limit on copy/paste Formula

topgunner

New Member
Joined
Aug 24, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to figure out how to limit copy/paste cell to a maximum of 8(A-H) columns on "Completed" sheet instead of the entire row because I need to use column 9(I) with another formula on the newly pasted values.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("G:G")) Is Nothing Then

If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub

Dim Lastrow As Long

Lastrow = Sheets("Completed").Cells(Rows.Count, "A").End(xlUp).Row + 1



If Target.Value = "Add" Then

Rows(Target.Row).Copy Destination:=Sheets("Completed").Rows(Lastrow)

Rows(Target.Row).Delete

End If

End If

End Sub


I tried following code after extensive search with no luck

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Target, Range("G:G")) Is Nothing Then

If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub

Dim Lastrow As Long

Lastrow = Sheets("Completed").Cells(Rows.Count, "A").End(xlUp).Row + 1



If Target.Value = "Add" Then

Range(Target.Row.Range(A:H)).Copy Destination:=Sheets("Completed").Rows(Lastrow)

Rows(Target.Row).Delete

End If

End If

End Sub


What am I doing wrong??? Thank you for any help I could get on this.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Replace
VBA Code:
Range(Target.Row.Range(A:H)).Copy Destination:=Sheets("Completed").Rows(Lastrow)
By
VBA Code:
Range(cells(Target.Row,"A"),cells(Target.Row,"H")).Copy Destination:=Sheets("Completed").Range("A" & Lastrow)
 
Upvote 0
Solution

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

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