View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.misc
Theresa Theresa is offline
external usenet poster
 
Posts: 55
Default Delete Null/Blank Rows

Hi Gord:

I found this code which works great:

Sub Delete_blank_rows()
Dim Lrow As Long
Dim CalcMode As Long
Dim StartRow As Long
Dim EndRow As Long
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

With ActiveSheet
.DisplayPageBreaks = False
StartRow = 11
EndRow = 500
For Lrow = EndRow To StartRow Step -1
If IsError(.Cells(Lrow, "A").Value) Then
'Do nothing, This avoid a error if there is a error in the
cell

ElseIf .Cells(Lrow, "A").Value = "" Then .Rows(Lrow).Delete

End If
Next
End With
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With
End Sub

Can you tell me how I can get this code to run when the sheet is made active?

Thanks.

"Gord Dibben" wrote:

Use the Macro Recorder to record the necessary autofilter steps then run that
code from a beforeprint event in Thisworkbook.


Gord Dibben MS Excel MVP

On Mon, 17 Dec 2007 17:34:01 -0800, Theresa
wrote:

I am very familiar with autofilter, however, this sheet is for users with
very limited excel skills so I wanted to do it automatically.

"JMB" wrote:

You could try Autofilter. Select your table, turn on Autofilter
(Data/Filter/Autofilter). You should see some drop down arrows in your
header row. Click the arrow in the column you want to look in for blank
cells and select
"Blanks". This will hide rows that have non-blank cells. Select the
visible cells that are left in that column and click Edit/Delete Row. Then
turn off the Autofilter.

Be sure to practice on a copy of your data before deleting anything
permanently.

"Theresa" wrote:

Hi:

I have 2 spreadsheets. The first contains all data. The second is a sheet
that I want to print. This sheet is built with an IF statement:

A10=IF('Level A Price Book'!A6="Y",'Level A Price Book'!B6,"")
B10=IF(A10<"",VLOOKUP(A10,'Data File'!$A$2:$J$11700,2,FALSE),"")
C10=IF(A10<"",'Level A Price Book'!F6,"")

This results in a number of rows that appear blank but still contain the
formula. I need to be able to delete the "blank" rows. I have tried a
couple of VBA scripts that I found here, but they don't work because the rows
are not "blank".

Any help would be appreciated.

Thanks,