Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default deleting rows, endless loop maybe ?

Perhaps this is a dumb Q, but a brief experiment looking at ranges in
Immediate Window causes me to ask this question. Will the following
(with correct syntax) cause an endless loop since the cells shifting
into the range will be empty?

range = a1:a10 (for example)
for each empty cell in range, delete the row

a11, a12, etc are in fact empty.

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default deleting rows, endless loop maybe ?

No, it will cause you to miss some cells. for example, if rows 2, 3 and 4
are emty, it will delete 2 and 4 and miss 3.

Usually one loops from higher to lower

for i = 10 to 1 step -2
if isempty(cells(i,1)) then
rows(i).Delete
End if
Next



--
Regards,
Tom Ogilvy


"dick" wrote in message
ps.com...
Perhaps this is a dumb Q, but a brief experiment looking at ranges in
Immediate Window causes me to ask this question. Will the following
(with correct syntax) cause an endless loop since the cells shifting
into the range will be empty?

range = a1:a10 (for example)
for each empty cell in range, delete the row

a11, a12, etc are in fact empty.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default deleting rows, endless loop maybe ?

got the idea, but, why step -2 instead of -1 ?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default deleting rows, endless loop maybe ?

It should be step -1. Sorry. Guess I had 2 still on the mind from the
exciting explantion I gave <g.

--
Regards,
Tom Ogilvy


"dick" wrote in message
oups.com...
got the idea, but, why step -2 instead of -1 ?



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
Endless spreadsheet calculations Zsolt Szabó Excel Discussion (Misc queries) 0 September 22nd 09 03:22 AM
file won't open, endless loop, autorecover lindalou Excel Discussion (Misc queries) 1 January 20th 08 01:26 AM
How can I make endless row, beyond IV column? Luciano New Users to Excel 2 January 23rd 06 04:08 PM
Interrupting an endless loop davegb Excel Programming 3 March 17th 05 05:06 PM
Endless Loop when using ComboBox1.BoundColumn = 2 shrekut Excel Programming 2 January 12th 04 01:46 PM


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

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

About Us

"It's about Microsoft Excel"