View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Don Guillett Don Guillett is offline
external usenet poster
 
Posts: 10,124
Default Can I delete blank rows from excel without selecting them?

One way would be to use datafilterautofilterfilter both on blanks. I just
recorded this. Clean it up to remove selections

Sub Macro1()
'
' Macro1 Macro
'

'

Range("A1:B8").Select
Selection.AutoFilter
ActiveSheet.Range("$A$1:$B$8").AutoFilter Field:=1, Criteria1:="="
ActiveSheet.Range("$A$1:$B$8").AutoFilter Field:=2, Criteria1:="="
Range("A2:B6").Select
Selection.EntireRow.Delete
Selection.AutoFilter
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"OzWaz" wrote in message
...
I have a similar problem with an import into Excel2007. 45,000+ rows
populating just col A & B and I wish to delete only rows where both col A
and
col B are blank. I tried modifying the sub below to the range "A:B" but
deletes everything. Can someone help?

"Bernie Deitrick" wrote:

The easiest way is to select all the cells and then sort, which puts
blanks (depends on what you
mean by NULL values) to the bottom. Of course, if you sort, that would
change the order, so
sometimes a macro like this might be better, which will delete any row
where column A is truly
blank:

Sub DeleteRowsBasedOnBlankCellsInColumnA()
On Error Resume Next
Columns("A:A").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
End Sub

HTH,
Bernie
MS Excel MVP


"rgtest" wrote in message
...
I exported data from a Crystal Report into Excel. During the export
process
extra fields and and columns were added to the data set. I would like
to
delete the blank rows that were inserted between every record from my
spreadsheet.

Is there a way to delete extra rows from a spreadsheet without
selecting
each row? For example, could I run a script to delete rows with null
values
or space?

Thanks