Delete Consecutive Rows if counta(row #) is =

  • Thread starter Thread starter Avi
  • Start date Start date
A

Avi

Hi,

I want to remove all the rows in used cells, when there are only 2
filled cells in any row. I am using following code

ActiveSheet.UsedRange.Select
For Each rw In Selection.Rows
If WorksheetFunction.CountA(rw.EntireRow) = 2 Then
rw.EntireRow.Delete
End If
Next rw

My Problem is - If there there are two consecutive rows satisfing this
criterion, only one gets deleted. Can someone please suggest me an
efficient approach to do that. I want to avoid counters in loop to
make it good in performance. So if there is any row based or array
based logic, that can help me solve this, please share with me..


Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top