LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Bob is offline
external usenet poster
 
Posts: 972
Default Removing blank rows

I have a 1-column spreadsheet that contains data in column H (with a heading
in cell H1). Some rows in column H contain no data or a single space.
Starting with cell H2, I needed a macro that would examine each cell in
column H and automatically delete a row where no data or only 1 space exists.
The macro would terminate after reaching row 1,000. Someone else in this
forum proposed the following macro:

Set currentCell = Worksheets("Sheet1").Range("H2")
for each cell in range("H2:H1000")
Set nextCell = currentCell.Offset(1, 0)
If Len(currentCell.Value) <= 1 Then
currentCell.EntireRow.Delete
End If
Set currentCell = nextCell
Next

Unfortunately, when I run the macro the first time, SOME rows with cells
whose LEN<=1 still remains! When I run the macro a second time, it then
catches and removes those remaining rows. Does anyone have any idea why I
need to run the aforementioned macro twice for it to truly complete the job?

I would greatly appreciate any help. Thanks.

Bob

 
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
Removing Blank Rows ? Robert11 New Users to Excel 3 November 13th 06 03:07 PM
Removing blank rows Carlton Patterson Excel Programming 2 July 17th 05 12:02 PM
Removing blank rows in a worksheet Louise Excel Worksheet Functions 6 May 26th 05 02:21 PM
Copying and pasting a worksheet to a blank and removing blank rows Bob Reynolds[_3_] Excel Programming 0 June 24th 04 02:55 PM
Removing Blank Rows? andycharger[_35_] Excel Programming 3 June 24th 04 02:09 AM


All times are GMT +1. The time now is 06:12 PM.

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"