PC Review


Reply
Thread Tools Rate Thread

Delete row if all cells are blank, Excel 2000 & 2003

 
 
jamesfc30@gmail.com
Guest
Posts: n/a
 
      14th Dec 2007
Hello,

I have a worksheet with 1061 rows and 7 columns of data.

Example:
column A B C D E
aa bb cc
vv
mm
blank row
ss

I'm need a macro to delete only the blank rows. I've tried the
following macro but it deletes a row when it finds a empty cell. Can
this macro be modified to delete a row with all empty cells only?

Sub DeleteRowsExampleB()
'Delete Selected Rows with specified data
Dim c As Range
Dim x As Range
Set x = Selection
For Each c In x
If c.Value = "" Then
c.EntireRow.Delete
End If
Next c
End Sub

Thank you for your help,
jfcby
 
Reply With Quote
 
 
 
 
Ron de Bruin
Guest
Posts: n/a
 
      14th Dec 2007
Try this one

For more info see
http://www.rondebruin.nl/delete.htm

Sub Loop_Example()
Dim Firstrow As Long
Dim Lastrow As Long
Dim Lrow As Long
Dim CalcMode As Long
Dim ViewMode As Long

With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

'We use the ActiveSheet but you can replace this with
'Sheets("MySheet")if you want
With ActiveSheet

'We select the sheet so we can change the window view
.Select

'If you are in Page Break Preview Or Page Layout view go
'back to normal view, we do this for speed
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView

'Turn off Page Breaks, we do this for speed
.DisplayPageBreaks = False

'Set the first and last row to loop through
Firstrow = .UsedRange.Cells(1).Row
Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row

'We loop from Lastrow to Firstrow (bottom to top)
For Lrow = Lastrow To Firstrow Step -1

If Application.CountA(.Rows(Lrow)) = 0 Then .Rows(Lrow).Delete

Next Lrow

End With

ActiveWindow.View = ViewMode
With Application
.ScreenUpdating = True
.Calculation = CalcMode
End With

End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


<(E-Mail Removed)> wrote in message news:312d8fe7-c501-4817-a349-(E-Mail Removed)...
> Hello,
>
> I have a worksheet with 1061 rows and 7 columns of data.
>
> Example:
> column A B C D E
> aa bb cc
> vv
> mm
> blank row
> ss
>
> I'm need a macro to delete only the blank rows. I've tried the
> following macro but it deletes a row when it finds a empty cell. Can
> this macro be modified to delete a row with all empty cells only?
>
> Sub DeleteRowsExampleB()
> 'Delete Selected Rows with specified data
> Dim c As Range
> Dim x As Range
> Set x = Selection
> For Each c In x
> If c.Value = "" Then
> c.EntireRow.Delete
> End If
> Next c
> End Sub
>
> Thank you for your help,
> jfcby

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I make Excel 2003 treat blank cells as zero? Wortman Microsoft Excel Misc 2 20th Jul 2009 04:29 PM
Excel 2003 - PRODUCT worksheet function and blank cells Guest3731 Microsoft Excel Discussion 2 12th Sep 2008 02:53 PM
Number Cells skip blank cells, Excel 2000 & 2003 jfcby Microsoft Excel Programming 4 31st Jul 2007 03:02 PM
Importing an Excel file with blank cells - Access 2000 =?Utf-8?B?Q3VydA==?= Microsoft Access External Data 0 27th Jun 2005 08:44 PM
How do I delete duplicate cells in an Excel 2003 spreadsheet? =?Utf-8?B?c2NsYXJrZQ==?= Microsoft Excel Misc 1 5th Oct 2004 08:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:07 PM.