View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
stevebriz stevebriz is offline
external usenet poster
 
Posts: 195
Default Delete ANY blank rows on worksheet

ok here is another way

FIRST back up back up you spread sheet.
then
Go to ViewToolbars control toolbox.
Move you cursor over the top of the control toolbox until you see
"commandbutton"
Click on this and then click on you spreadsheet where you want to place
it( it does not really matter where you place the command button on the
spread sheet.)
then double click it and the VB editor will open

paste the code below between the Private Sub CommandButton1_Click() and
the End Sub.
Press F5 and the code will run and do its thing. PLEASE:Remember if
you do this- IT CAN NOT BE UNDONE. this is not reversible.
go back to you spread sheet and all the blank rows should be gone.
You can then delete the button you added if you want (double clicking
on the button reruns the code) To Delete the button- click once and
press Delete.

If you want to go back to where the code is press ALT & F11
you can delect all the code if you like too ( now that you finished
with it) To do this Highlight all and hit delete.
Close Vb editor and then you can save your work book
Done

Hope this helps
'-------------------------------------------------------
'Deletes the entire row within the selection if the ENTIRE row contains
no data.

'We use Long in case they have over 32,767 rows selected.
Dim i As Long

'We turn off calculation and screenupdating to speed up the macro.
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False

'We work backwards because we are deleting rows.
For i = Selection.Rows.Count To 1 Step -1
If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
Selection.Rows(i).EntireRow.Delete
End If
Next i

.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
End With

'-------------------------------------------------------