Excel

Prompt message when inserting or deleting a row

Ease of Use

Easy

Version tested with

5 and later 

Submitted by:

Paleo

Description:

Everytime you insert or delete a row it will prompt you with a message. 

Discussion:

Sometimes we need to send a message to our user everytime he/she inserts/deletes a row. 

Code:

instructions for use

			

In Module 1: Public gintRow As Integer In This_Workbook: Option Explicit Private Sub Workbook_Open() gintRow = Range("Last").Row End Sub In Sheet1: Option Explicit Private Sub Worksheet_Calculate() If Range("Last").Row < gintRow Then MsgBox "The row is deleted!" ElseIf Range("Last").Row > gintRow Then MsgBox "The row is added!" End If gintRow = Range("Last").Row End Sub

How to use:

  1. Simply use the example file and whenever you insert or delete a row a msgbox will be shown.
 

Test the code:

  1. Copy the above code.
  2. Open any workbook.
  3. Press Alt + F11 to open the Visual Basic Editor (VBE).
  4. From the Menu, choose Insert-Module.
  5. Paste the code into the stated code window.
  6. Close the VBE, save the file if desired.
 

Sample File:

MessageWhenDeleteOrInsertRows.zip 7.4KB 

Approved by mdmackillop


This entry has been viewed 148 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express