![]() |
|
|
|
#1
|
|||
|
|||
|
Dear Sir
We need your help Each day we do thousand of sheets like as follow workdone. We need to count the latest 15 records. For more than 15 records, we delete as Yellow color row. That is the old record we need to delete. For less than 15 records, We delete the yellow color row. After VBA code, The final result should be same as file named after. Attached pls find two file name before ,after The vba code don’t work…pls help..many thanks lastRow = Cells(Rows.Count, 1).End(xlUp).Row For z = 1 To lastrow If (Cells(z, ("c"))) = "" Then Cells(z, ("c")).EntireRow.Clear Next z Many Thanks Tom |
|
#2
|
|||
|
|||
|
Hi,
How do you determine the "Old Record". |
|
#3
|
|||
|
|||
|
I believe this does what you're asking, although it doesn't match your after file.
Code:
Sub tomlam()
' remove rows with blank "C" and limit to 15
Dim lr As Long
Dim r As Long
Dim i As Integer
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
'delete rows where C is blank
Range("C1", Cells(Rows.Count, "C").End(xlUp)).SpecialCells(xlBlanks).EntireRow.Delete
'limit to 15
lr = Cells(Rows.Count, "C").End(xlUp).Row
For r = lr To 2 Step -1
If Cells(r, "C").Value = "total export" Then
i = 0
Else
i = i + 1
End If
If i > 15 Then Rows(r).Delete
Next r
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
|
|
#4
|
|||
|
|||
|
Many Thanks to Nosparks. It is great ...solved....
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Getting the Count formula to count all rows
|
Jennifer Murphy | Word Tables | 11 | 08-23-2016 09:37 PM |
| How to Delete the same watermark that are in 300 slides. I cant dare to manually delete. | yeshwanthkota111 | PowerPoint | 0 | 09-05-2015 10:03 AM |
Delete starting number *) and delete Unneeded data in series
|
frustrated teacher | Word VBA | 5 | 12-07-2014 06:53 PM |
| Delete option greyed out when trying to delete row 1 | tpcervelo | Excel | 2 | 11-15-2011 06:48 AM |
| delete email message via blackberry and have it delete on my pop3 and my outlook | Iamthestorm | Outlook | 2 | 10-28-2010 12:21 AM |