View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default macro to delete empty cells

Sub RemoveEmptyCells_ShiftUp()
Application.ScreenUpdating = False
Application.Calculation = xlManual
Dim rw As Long, iCol As Long
For rw = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
If isempty(cells(rw,1)) Then _
cells(rw,1).Delete Shift:=xlShiftUp
Next
Application.Calculation = xlAutomatic
Application.ScreenUpdating = True
End Sub

This deletes blank cells in Column A ( second argument of cells is 1) and
shifts the cell up.

--
Regards,
Tom Ogilvy


"Todd" wrote in message
...
Hi, I am playing with a marcro to delete empty cells. I
have a macro that deletes empty rows and I thought I could
basically change "rows" to "cells" and it would work. But
I guess its not that simple. Can someone tell me what I
need to make this work?

TIA

Todd.

Here is the origonal macro.

Sub RemoveEmptyRows()
Application.ScreenUpdating = False 'xlManual below in
Xl95
Application.Calculation = xlCalculationManual
Dim rw As Long, iCol As Long
For rw = ActiveSheet.UsedRange.Row.Count To 1 Step -1
If Application.CountA(Rows(rw).Entirecell) = 0 Then _
Rows(rw).Delete
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True 'xlAutomatic above
in xl95
End Sub