Excel

Automatically Delete Rows Based On User Input

Ease of Use

Easy

Version tested with

2002 

Submitted by:

Jacob Hilderbrand

Description:

This macro deletes an entire row based on a specific input. 

Discussion:

You want to delete a row easily, and this macro allow just that. Input a "d" in Column C and that row is automatically deleted. 

Code:

instructions for use

			

Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) If Not Target.Column = 3 Then Exit Sub End If If Target(1, 1).Value = "d" Then Target(1, 1).EntireRow.Delete End If End Sub

How to use:

  1. Open Excel.
  2. Right click on the sheet tab that you wan to code to work on and select View Code.
  3. Paste the code in the Code Window that opens up.
  4. Close the VBE (Alt + Q or press the X in the top-right corner).
 

Test the code:

  1. Type d in any cell in Column C and that row is immediately deleted.
 

Sample File:

DeleteRows.zip 6KB 

Approved by mdmackillop


This entry has been viewed 236 times.

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