Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Delete blank rows if more than one | Excel Discussion (Misc queries) | |||
How do I delete blank rows (rows alternate data, blank, data, etc | Excel Discussion (Misc queries) | |||
delete blank rows | Excel Discussion (Misc queries) | |||
Delete Blank rows | Excel Programming | |||
Delete blank row only if 2 consecutive blank rows | Excel Programming |