Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default macro to delete empty cells

Todd,

I have found using the Recorder with a dummy workbook is a great way to find
code for various situations. I use this all the time when building new code
(either because I don't know, or have forgotton).

Don't forget the Help function. (not always easy to find what you want, but
most of what you want is in there some where)

When that fails, I search Google. Go to this site and download the Google
Search Add-In (its a great help)
www.rondebruin.nl/Google.htm

And than I follow the ng. Lots of great stuff. And they constantly answer
my questions (no matter how dumb they may be).

steve

"Todd" wrote in message
...
Thanks so much,

How would I change this to get it to shift in different
directions? I have been looking on the net for a page of
basic commands so I can learn this but haven't found
anything yet.


Todd




-----Original Message-----
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



.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default macro to delete empty cells

It can only shift up or shift to the left.

so the argument would be xltoLeft

highlight the delete command in the module and hit F1 to see the help file
with the options.


--
Regards,
Tom Ogilvy

"Todd" wrote in message
...
Thanks so much,

How would I change this to get it to shift in different
directions? I have been looking on the net for a page of
basic commands so I can learn this but haven't found
anything yet.


Todd




-----Original Message-----
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



.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro to delete empty cells

Thanks again, you both have been great

Todd
-----Original Message-----
It can only shift up or shift to the left.

so the argument would be xltoLeft

highlight the delete command in the module and hit F1 to

see the help file
with the options.


--
Regards,
Tom Ogilvy

"Todd" wrote in message
...
Thanks so much,

How would I change this to get it to shift in different
directions? I have been looking on the net for a page

of
basic commands so I can learn this but haven't found
anything yet.


Todd




-----Original Message-----
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


.



.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete row if 2 cells are empty Wanna Learn Excel Discussion (Misc queries) 1 November 19th 09 10:20 PM
delete cells column. Delete empty cells myshak Excel Worksheet Functions 0 March 9th 09 10:59 PM
How do I delete rows where cells are empty Stan Excel Discussion (Misc queries) 2 January 2nd 08 05:49 AM
Delete Empty Cells in a Macro fak119 Excel Discussion (Misc queries) 3 January 9th 07 04:58 PM
Delete Row If Empty Macro Richard Excel Discussion (Misc queries) 3 January 20th 06 11:26 PM


All times are GMT +1. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"