Autodelete a row from protected sheet and move to another protected sheet based on date

SaraWitch

Active Member
Joined
Sep 29, 2015
Messages
377
Office Version
  1. 365
Platform
  1. Windows
Hello peeps,

In a protected sheet ("Placements"), I have a formula in column U that calculates a date from a range of other cells. When a date is populated, I want the row to automatically delete and paste into another protected sheet ("Leavers"). I think I'm almost there with the formula below but know I have to change the <> in line 4 (I've tried some date text but it doesn't work).

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect ("password")
    Dim NextRow As Long
    If Target.Column <> 21 Then Exit Sub
    Application.EnableEvents = False
    With Sheets("Leavers")
        NextRow = .Cells(Rows.Count, 8).End(xlUp).Row + 1
        Target.EntireRow.Copy Destination:=.Cells(NextRow, 1)
        Target.EntireRow.Delete
    End With
    Application.EnableEvents = True
ActiveSheet.Protect ("password")
End Sub

Any help would be gratefully received :)
 
Can you upload a copy of your file to a free file hosting site like www.box.com/personal or www.dropbox.com, mark the file for sharing and post the link it provides in your original thread.

Before uploading
1) make sure you sanitize any sensitive data
2) change the passwords on the sheets to something different
3) post the new sheet passwords in the thread so that we can test

Btw, I ran the code that you posted in post number 10 on some sample data with Left in various cells in column G via formula (on unprotected sheets obviously), and it copied the data to the sheet Exceeded fine
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
In future please do not "hijack" other peoples threads with your own question. Especially when it duplicates this thread.
I have moved the replies over.
 
Upvote 0
Thank you, @Fluff. I thought linking the two threads would be sufficient, so, apologies, and thank you for moving the replies over.

@MARK858, here is a link to the workbook: EA Placement Manager.xlsm. Any help you can offer would be gratefully received...
Happy new year, @MARK858!

I wonder if you have had a chance to have a look at this? I'm really not sure why it's not working? :unsure:
 
Upvote 0
VBA Code:
Sub Move_Row_to_Leavers_Sheet()
    Dim lr As Long, i As Long
    Worksheets("EBC EA Leavers").Unprotect
    
    For i = Sheets("EBC EA Placements").Columns(3).Find("*", , xlValues, , xlByRows, xlPrevious).Row To 8 Step -1
        
        If Sheets("EBC EA Placements").Cells(i, 22).Value = "Left" Then
            
            
            With Worksheets("EBC EA Leavers")
                lr = .Columns(3).Find("*", , xlValues, , xlByRows, xlPrevious).Row
                
                If lr < 8 Then
                    Sheets("EBC EA Placements").Cells(i, 22).EntireRow.Copy .Cells(8, 1)
                    Sheets("EBC EA Placements").Cells(i, 22).EntireRow.Delete
                Else
                    Sheets("EBC EA Placements").Cells(i, 22).EntireRow.Copy .Cells(lr + 1, 1)
                    Sheets("EBC EA Placements").Cells(i, 22).EntireRow.Delete
                End If
               
            End With
       
       End If
    
    Next
End Sub

or use the autofilter
 
Upvote 0
Solution
Strange, it works for me with the file you uploaded 😂

Look at the "EBC EA Leavers" sheet
Then go to the "EBC EA Placements" sheet and click the button that I have put there
Then look at the result in the "EBC EA Leavers" sheet

Edit: file deleted at OP's request
 
Last edited:
Upvote 0
Ahhhh! Perfect (I wasn't assigning as a macro! :rolleyes:)! I just need it to work with password protection on both sheets - is this possible? And is it further possible to re-protect the sheets with the same password the row/s have moved?
 
Upvote 0
I shall reboot and try with a smaller section, if that would help...?
That is a very odd post for your first post when you weren't the one to post the original question...
Not really sure if you are trying to help or asking for help.
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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