Delete row

AndyD

Active Member
Joined
Nov 14, 2002
Messages
449
hi
I want to be able to type "x" in a cell in column A and for it to delete the whole row automatically.
if could supply code would be very grateful
Cheers
Andy
 

Some videos you may like

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Datsmart

Well-known Member
Joined
Jun 19, 2003
Messages
7,985
Put this code in the WorkSheet module of the page you want it to work on.
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
    FinalRow = Range("A65536").End(xlUp).Row
    For x = FinalRow To 1 Step -1
        If Cells(x, "A").Value = "x" Then
            Rows(x).Delete Shift:=xlUp
        End If
    Next x

End Sub
Right click the sheet tab you want to have the code act on.
Choose "View Code"
Paste the code in the panel that opens, then close VBA editor.
 

Watch MrExcel Video

Forum statistics

Threads
1,111,599
Messages
5,541,166
Members
410,543
Latest member
ExcelGlenn
Top