Using VBA code that will move a row to another sheet based on the selection from a drop-down menu. How to get it to work when protecting the sheet

Phil 0 Reputation points
2025-10-27T16:47:03.8566667+00:00

Hello there,

I'm looking for some help in using VBA code on excel. I have several sheets set up so that when I select from a drop down, some information is copied to other sheets and the line is deleted from the 'Register'.

The problem - I have the sheets protected to prevent certain areas being changed/amended. The users are only able to fill certain areas of the sheets. This VBA code won't work when the sheets are protected. Any help would be greatly appreciated. The current VBA code is:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ws As Worksheet

Dim rng As Range

Dim lastRow As Long

'Check if the changed cell is in column Z (Status)

If Target.Column = 26 Then

'Get the selected worksheet name

Set ws = Worksheets(Target.Value)

'Get the last row in the selected worksheet

lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row + 1

'Copy the row to the selected worksheet

Set rng = Range("A" & Target.Row & ":D" & Target.Row)

rng.Copy ws.Range("A" & lastRow)

'Delete the row from the Register sheet

rng.Delete Shift:=xlUp

End If

End Sub

Microsoft 365 and Office | Excel | Other | Windows
0 comments No comments

2 answers

Sort by: Most helpful
  1. IGYQ 22,340 Reputation points Independent Advisor
    2025-10-27T17:44:54.59+00:00

    Let me know once done so I assist you further.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.