Move a row to another sheet based on data manually changed - Help - on the verge of tears

buxinsix

New Member
Joined
Nov 5, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
I found a code on another post that does almost exactly what I want my spreadsheet to do, but I’ve tried changing the code to align with my sheet and I somehow mess it up.

On a sheet called “Contact Log” if I change column H to “Active Client” (manually) I want it to automatically copy that row to a spreadsheet called “Lead Status” I do not want it to delete the row. I want it to copy the entire row to column A, row 2 and on.

I’ve tried changing this code and it almost works. The first time I change a cell to active client it’ll copy the row, but it copies the data to column N, stops after the first few data changes, or it copies each time but only to column N, row 2, which means it continuously replaces the data.

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 = 2 And Target.Row > 5 And Target.Value = "Yes" Then
Application.EnableEvents = False
' Copy columns B to I to complete sheet in next available row
Range(Cells(Target.Row, "B"), Cells(Target.Row, "I")).Copy Sheets("Complete").Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
' Delete current row after copied
Rows(Target.Row).Delete
Application.EnableEvents = True
End If

End Sub

 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab you want row copied from
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  11/6/2022  10:38:00 PM  EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 8 Then
Application.ScreenUpdating = False
Dim ans As String
ans = "Lead Status"
Dim r As Long
Dim Lastrow As Long
r = Target.Row
    If Target.Value = "Active Client" Then
        Lastrow = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1
        Rows(r).Copy Sheets(ans).Cells(Lastrow, 1)
    End If
Application.ScreenUpdating = True

End If
End Sub
 
Upvote 0
Solution
Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab you want row copied from
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  11/6/2022  10:38:00 PM  EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 8 Then
Application.ScreenUpdating = False
Dim ans As String
ans = "Lead Status"
Dim r As Long
Dim Lastrow As Long
r = Target.Row
    If Target.Value = "Active Client" Then
        Lastrow = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1
        Rows(r).Copy Sheets(ans).Cells(Lastrow, 1)
    End If
Application.ScreenUpdating = True

End If
End Sub
It worked! Thank you so freakin much.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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