Delete rows with counta < 13

MegloManiac

New Member
Joined
Jan 5, 2010
Messages
23
Hello,

I have a automated weekly report from our ERP which we copy into excel. The data is not yet ready for proper analysis. Most of the steps I can record in a macro except for one. I want to remove all rows where the counta < 13 for the columns A through N. I can do this by adding the formula =counta(A2:N2) and filling this for all rows and then filter on <13 and delete those rows, but I am sure there is a better way to build this in VBA only I don't how :) It should check from row 2 until the last filled line (which is variable per week)

thanks!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Try

Code:
Sub test()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 2 Step -1
    If WorksheetFunction.CountA(Range("A" & i).Resize(, 14)) < 13 Then Rows(i).Delete
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top