Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default Delete Consecutive Rows if counta(row #) is =

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Delete Consecutive Rows if counta(row #) is =

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" wrote in message ...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Transposing data from consecutive rows into non-consecutive rows econ Excel Discussion (Misc queries) 0 March 10th 08 07:24 PM
How to delete CONSECUTIVE duplicate Rows Fred Excel Programming 1 September 23rd 07 01:57 PM
Counta and rows.. Ju Excel Worksheet Functions 9 February 20th 06 03:22 PM
Inserting multiple rows in excel with data in consecutive rows technotronic Excel Programming 2 October 20th 05 03:12 PM
Delete blank row only if 2 consecutive blank rows Amy Excel Programming 2 October 21st 04 05:24 PM


All times are GMT +1. The time now is 04:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"