Help with Auto Archiving Data

jdodge92

New Member
Joined
Apr 28, 2022
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am trying to set my worksheet to automatically move a row from one Sheet "Awaiting Collection" to another Sheet called "Archive" when a "Y" is entered in to a cell in Column G. I would like the data to then be removed from the Sheet "Awaiting Collection" once it has been moved on to the Sheet "Archive".

I have been trying various different codes that I have found on other posts on this forum and from other sources but I cant seem to get any to do exactly what I want when I change to suit my set up.

If anyone would be able to point me in the right direction then that would be great!

Many Thanks,
Jordan
 

Attachments

  • Picture2.png
    Picture2.png
    70.9 KB · Views: 4

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this in the sheet module of the "Awaiting Collection" sheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim lr As Long
    
    With Target
        If .Rows.Count = 1 And .Column = Columns("G").Column Then
            If .Value = "Y" Then
                lr = Worksheets("Archive").Cells(Rows.Count, "A").End(xlUp).Row
                .EntireRow.Copy Worksheets("Archive").Cells(lr + 1, "A")
                Application.EnableEvents = False
                .EntireRow.Delete
                Application.EnableEvents = True
            End If
        End If
    End With
    
End Sub
 
Upvote 0
Solution
Try this in the sheet module of the "Awaiting Collection" sheet:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    Dim lr As Long
  
    With Target
        If .Rows.Count = 1 And .Column = Columns("G").Column Then
            If .Value = "Y" Then
                lr = Worksheets("Archive").Cells(Rows.Count, "A").End(xlUp).Row
                .EntireRow.Copy Worksheets("Archive").Cells(lr + 1, "A")
                Application.EnableEvents = False
                .EntireRow.Delete
                Application.EnableEvents = True
            End If
        End If
    End With
  
End Sub

[/QUOTE]
Perfect!! That's worked a dream!

Thanks Very Much
Jordan
 
Upvote 0

Forum statistics

Threads
1,215,729
Messages
6,126,524
Members
449,316
Latest member
sravya

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