In case the answer to either of these is 'Yes', you could try replacing the relevant section of my code with this.BTW, does your sheet have any formulas down those 170,000 rows and do you have any other code (eg Worksheet_Change code) in operation with the sheet?
If rws > 0 Then
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
With Range("A2").Resize(lr - 1)
.Offset(, lc).Value = tmp
.Resize(, lc + 1).Sort Key1:=.Cells(1, lc + 1), _
Order1:=xlAscending, Header:=xlNo
.Resize(rws).EntireRow.Delete
.Offset(, lc).ClearContents
End With
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End If
Excel Workbook | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | |||
1 | ID | PQ | Yea | Mon | Meet | Date | Day | Win | Place | Con | Con# | Weather | Rail | Time | Class | Dist | Stakes | R# | Fsz | Race Name | Placing | |||
2 | 225 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 1 | |||||
3 | 226 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 2 | |||||
4 | 227 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 3 | |||||
5 | 228 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 4 | |||||
6 | 229 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 5 | |||||
7 | 230 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 6 | |||||
8 | 231 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 7 | |||||
9 | 232 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 8 | |||||
10 | 233 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:00:00 p.m. | MDN | 2100 | $30,000.00 | 2 | 9 | 9 | |||||
11 | 242 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 1 | |||||
12 | 243 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 2 | |||||
13 | 244 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 3 | |||||
14 | 245 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 4 | |||||
15 | 246 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 5 | |||||
16 | 247 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 6 | |||||
17 | 248 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 7 | |||||
18 | 249 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 8 | |||||
19 | 250 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 9 | |||||
20 | 251 | PQ | 2006 | Mar | Tren | 18/03/2006 | Saturday | $0.00 | $0.00 | Good | Fine | True Position | 1:35:00 p.m. | 3YO HCP | 1200 | $20,000.00 | 3 | 10 | 10 | |||||
Sheet1 |
However, the formulas will recalculate during my code and that is likely to be slow with so many rows. Try replacing the section of code as described in post #21.The sheet does contain formulars but nothing to do with Col O .
Try this. Change this line - note the UPPER CASECan i get it to delete all except row 1 heading of course when cell equals MDN only . Not Mdn 3YO or Mdn C&G , keep Mdn , MDN , mDN , etc only .
Const LookForVal As String = "MDN"
If InStr(1, aCol(i, 1), LookForVal, 1) = 0 Then
If UCase(aCol(i, 1)) <> LookForVal Then
Assuming they are all in column O I would change the code structure a little.Peter if i wanted to delete all except MDN , Rating 90 , 3YO F , 0-4Wins , how do i write this too include my last 3 suggestions along as MDN as well .