Share via

rows getting deleted in error

Anonymous
2022-12-05T16:22:10+00:00

occasionally in my spreadsheet an entire row will come up missing (accidentally deleted). A few people work in this spreadsheet. Is there a way to have excel prompt your before allowing an entire row to be deleted?

Microsoft 365 and Office | Excel | Other | MacOS

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Jim G 134K Reputation points MVP Volunteer Moderator
    2022-12-23T22:21:17+00:00

    Hi Laura,

    In order to delete a row you have to take some intentional actions.

    On a worksheet there are two ways to delete a row.

    You can select a row by right-clicking on the row number to the left of the row. Then choose Delete from the menu.

    Another way is to right-click on a cell and then choose Delete and then choose Entire Row from the pop-up menu.

    If a row is accidentally deleted, it can always be undeleted by using the Undo function.

    Shakiru suggested that a macro could be made to provide an alert, but the instructions Shakiru provided are utter nonsense.

    Are you certain the missing rows were deleted and not hidden?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-12-05T17:24:39+00:00

    Hi Laura &!

    Thank you for writing to the Microsoft Answer Community Forum, I am Shakiru, an independent advisor and a user like you, and I am glad to be helping you out today.

    I'm sorry, This may be achieved with some level of VBA code.'

    However, you will need to enable the Macros. and then apply the code.

    To enable Macros: -Go to the File menu in Excel. -Scroll down to the Options menu. -Select Trust Center in the window that pops up. -Click the "Trust Center Settings" button on the bottom right of the "Trust Center" tab. -On the Trust Center choose the "Macro Settings" tab (left). -Enable all macros. -Click "OK", then "OK" again to apply.

    To enter a VBA code we first have to open the VBA window. You can either do it using keyboard shortcuts or from your Developer Tab. Press Ctrl+F11 to open the VBA Window.

    The following event macro will tell you whenever an entire row is deleted or inserted: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Rows.Count = 1 And Target.Columns.Count = Columns.Count Then MsgBox Target.Row End If End Sub

    Kind Regards, Shakiru

    Was this answer helpful?

    0 comments No comments