LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default For/Next using Thing

I have a spreadsheet with 40,000 records. The original
file is a .txt file that is formatted with page breaks: 13
rows for each page header, and then 25 rows/records of
actual data, 13 rows of page header, then 25 rows/records
of data, etc.

I am opening this file in MS Excel and performing
analysis. The first step in my macro is to delete all page
header rows and then delete all rows with no data so that
I end up with a table that contains only my data records.
Column A is blank for all rows that contain column heading
information.

I am using a For/Next statement to do this. It looks like
this:

Note: My selection is all rows in column A of the
spreadsheet

Sub DeleteHeader()
For Each thing In Selection

If thing.value = "" then
thing.entirerow.delete
Else
thing.font.bold = true
End If

Next thing
End Sub

Here is my problem: if I have two consecutive rows that
have blank data in column A, it deletes the first row, but
then skips the next row. Essentially, if thing is row#2
and it is blank, it deletes row#2 and moves all data in
the file up one record (so what was row#3 is now row#2).
Since the next value of thing is row#3, it skips what is
now row#2 and does not delete it if it is blank. As a
result, I am having to run through this Subroutine at
least twice to delete all blank records.

How can I have this routine recognize that if a row is
deleted that the value of "thing" needs to stay at its
present value? I am unable to do any sorts since I need
the data records to remain in the original sequence.


 
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
One Last Thing Coltsfan Excel Discussion (Misc queries) 1 January 16th 06 08:42 PM
Is there such a thing... Tom Excel Discussion (Misc queries) 1 April 19th 05 01:38 AM
Doing it's own thing André Excel Programming 3 July 9th 04 11:30 PM
Another thing Richard Excel Programming 0 May 21st 04 04:21 PM
oh, and another thing ted daniels Excel Programming 2 April 22nd 04 05:34 PM


All times are GMT +1. The time now is 02:37 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"