PC Review


Reply
Thread Tools Rate Thread

Delete Blank Rows in a pattern

 
 
GregR
Guest
Posts: n/a
 
      2nd Jul 2007
I have a spreadsheet that beginning in Row 6 has data every thrid row
for about 7500 rows. I want to delete all blank rows to the last
filled row. The pattern is such;
Blank
Blank
Data
Blank
Blank
Data
Blank
Blank
Data.............etc
Is there a fast way in code to segregate the blank rows and delete
them all? TIA

Greg

 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      2nd Jul 2007
use autofilter the filter the blank rows then delete them

--


Gary


"GregR" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a spreadsheet that beginning in Row 6 has data every thrid row
> for about 7500 rows. I want to delete all blank rows to the last
> filled row. The pattern is such;
> Blank
> Blank
> Data
> Blank
> Blank
> Data
> Blank
> Blank
> Data.............etc
> Is there a fast way in code to segregate the blank rows and delete
> them all? TIA
>
> Greg
>



 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      2nd Jul 2007
Dim rng As Range
Set rng = Columns(1).SpecialCells(xlCellTypeBlanks)
rng.EntireRow.Delete


--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"GregR" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a spreadsheet that beginning in Row 6 has data every thrid row
> for about 7500 rows. I want to delete all blank rows to the last
> filled row. The pattern is such;
> Blank
> Blank
> Data
> Blank
> Blank
> Data
> Blank
> Blank
> Data.............etc
> Is there a fast way in code to segregate the blank rows and delete
> them all? TIA
>
> Greg
>



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      2nd Jul 2007
Greg,

The following code will delete the rows whose value in column A is blank.
Note that the code works from the bottom of the list moving upwards. This
is done to prevent the RowNdx variable from pointing to the wrong row after
a Delete operation. As a generaul rule, if you have loops that either Insert
or Delete a row, you should always work from the bottom of the list and move
upwards to the top of the list.


Sub AAA()
Dim LastRow As Long
Dim StartRow As Long
Dim RowNdx As Long

StartRow = 1 '<<< CHANGE AS DESIRED
With ThisWorkbook.Worksheets("Sheet1") '<<< CHANGE SHEET NAME AS DESIRED
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To StartRow Step -1
If .Cells(RowNdx, "A").Value = vbNullString Then
.Rows(RowNdx).Delete
End If
Next RowNdx
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"GregR" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a spreadsheet that beginning in Row 6 has data every thrid row
> for about 7500 rows. I want to delete all blank rows to the last
> filled row. The pattern is such;
> Blank
> Blank
> Data
> Blank
> Blank
> Data
> Blank
> Blank
> Data.............etc
> Is there a fast way in code to segregate the blank rows and delete
> them all? TIA
>
> Greg
>


 
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
Delete Rows if any cell in Column H is blank but do not Delete Fir =?Utf-8?B?bWFuZmFyZWVk?= Microsoft Excel Programming 4 28th Sep 2007 05:20 PM
How do I delete blank rows (rows alternate data, blank, data, etc =?Utf-8?B?bmNvY2hyYXg=?= Microsoft Excel Misc 2 27th Jun 2007 04:40 AM
Delete all blank rows... =?Utf-8?B?Ym91cmJvbjg0?= Microsoft Excel Misc 2 4th Oct 2006 02:13 PM
Delete blank row only if 2 consecutive blank rows =?Utf-8?B?QW15?= Microsoft Excel Programming 2 21st Oct 2004 05:24 PM
Delete blank rows Andy B Microsoft Excel Misc 1 2nd Oct 2003 09:34 AM


Features
 

Advertising
 

Newsgroups
 


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