I have the following code below that where text "AC060" appears in Col A, it must delete this row and the next 6 rows including the row containing AC060
However, nothing happens when I activate the code. I have also copied sample data
Your assistance in resolving the problem will be most appreciated
Sub Delete_Unwanted()
Dim LR As Long, i As Long
For i = 6 To LR
LR = Range("A" & Rows.Count).End(xlUp).Row
If Range("A" & i).Value = "AC060" Then Range("A" & i).Resize(6).EntireRow.Delete
Next i
End Sub
However, nothing happens when I activate the code. I have also copied sample data
Your assistance in resolving the problem will be most appreciated
Sub Delete_Unwanted()
Dim LR As Long, i As Long
For i = 6 To LR
LR = Range("A" & Rows.Count).End(xlUp).Row
If Range("A" & i).Value = "AC060" Then Range("A" & i).Resize(6).EntireRow.Delete
Next i
End Sub
Excel Workbook | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
1 | A-712536 | GEN | 31/10/2010 | -2500000 | |||
2 | A-712536 | GEN | 31/10/2010 | -500000 | |||
3 | A-712536 | GEN | 31/10/2010 | -250000 | |||
4 | A-712536 | GEN | 31/10/2010 | -1000000 | |||
5 | A-712536 | GEN | 31/10/2010 | -1000000 | |||
6 | A-712536 | GEN | 31/10/2010 | -1000000 | |||
7 | A-712536 | GEN | 31/10/2010 | -500000 | |||
8 | A-712536 | GEN | 31/10/2010 | -1200000 | |||
9 | A-712536 | GEN | 31/10/2010 | -1700000 | |||
10 | A-712536 | GEN | 31/10/2010 | 500000 | |||
11 | A-712536 | GEN | 31/10/2010 | 500000 | |||
12 | AC060 | CE | |||||
13 | etailed | ||||||
14 | |||||||
15 | Accoun | / | Dates: 01/ | Control#s: ALL | |||
16 | A/C No | Ref No | JRN | Date | Amount | ||
17 | ------ | ------ | --- | ---------- | ------------- | ||
18 | A-712536 | GEN | 31/10/2010 | 500000 | |||
19 | A-712536 | GEN | 31/10/2010 | 1500000 | |||
20 | A-712536 | GEN | 31/10/2010 | 1500000 | |||
21 | A-712815 | GEN | 31/10/2010 | 300000 | |||
22 | A-712815 | GEN | 31/10/2010 | 150000 | |||
23 | A-712815 | GEN | 31/10/2010 | 550000 | |||
24 | A-712815 | GEN | 31/10/2010 | -700000 | |||
25 | A-712815 | GEN | 31/10/2010 | -300000 | |||
26 | A-712805 | GEN | 31/10/2010 | 750000 | |||
27 | |||||||
28 | |||||||
29 | |||||||
30 | |||||||
Sheet1 |