PC Review


Reply
Thread Tools Rate Thread

Delete Consecutive Rows if counta(row #) is =

 
 
Avi
Guest
Posts: n/a
 
      4th Aug 2008
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!
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      4th Aug 2008
Hi Avi

When you delete rows always start at the botom an go up

See
http://www.rondebruin.nl/delete.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Avi" <(E-Mail Removed)> wrote in message news:0b6f523f-56d2-4c45-9a99-(E-Mail Removed)...
> 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!

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transposing data from consecutive rows into non-consecutive rows econ Microsoft Excel Misc 0 10th Mar 2008 07:24 PM
How to delete CONSECUTIVE duplicate Rows =?Utf-8?B?RnJlZA==?= Microsoft Excel Programming 1 23rd Sep 2007 01:57 PM
Counta and rows.. Ju Microsoft Excel Worksheet Functions 9 20th Feb 2006 03:22 PM
Inserting multiple rows in excel with data in consecutive rows =?Utf-8?B?dGVjaG5vdHJvbmlj?= Microsoft Excel Programming 2 20th Oct 2005 03:12 PM
Delete blank row only if 2 consecutive blank rows =?Utf-8?B?QW15?= Microsoft Excel Programming 2 21st Oct 2004 05:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:03 PM.