Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 246
Default Delete Blank Rows in a pattern

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Delete Blank Rows in a pattern

use autofilter the filter the blank rows then delete them

--


Gary


"GregR" wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Delete Blank Rows in a pattern

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" wrote in message
oups.com...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Delete Blank Rows in a pattern

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" wrote in message
oups.com...
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
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
Delete blank rows if more than one Kjellk Excel Discussion (Misc queries) 5 June 10th 09 06:17 AM
How do I delete blank rows (rows alternate data, blank, data, etc ncochrax Excel Discussion (Misc queries) 2 June 27th 07 04:40 AM
delete blank rows Pam C Excel Discussion (Misc queries) 1 January 17th 06 07:13 PM
Delete Blank rows Sige Excel Programming 8 September 27th 05 03:50 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 12:19 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"