Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Easy Question

I need to check each row of a database to ensure it is not blank (this is
performed after importing data from an external source).

If the cell is blank, I need to delete the entire row.

The problem I'm having is if two blank rows are next to each other. The
routine I use does not delete the second row, because of the deletion of the
first one.

How do I 'reset' the variable to the row before the deletion, so that the
routine catches the second blank row?

For Each cl In Range("A2:A" & Range("A65500").End(xlUp).Row).Cells
If cl = Empty Then
cl.EntireRow.Delete
End If
Next

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Easy Question

Try this statement to delete instead.

SpecialCells(xlCellTypeBlanks).Delete Shift:=xlUp

"Posse John" wrote:

I need to check each row of a database to ensure it is not blank (this is
performed after importing data from an external source).

If the cell is blank, I need to delete the entire row.

The problem I'm having is if two blank rows are next to each other. The
routine I use does not delete the second row, because of the deletion of the
first one.

How do I 'reset' the variable to the row before the deletion, so that the
routine catches the second blank row?

For Each cl In Range("A2:A" & Range("A65500").End(xlUp).Row).Cells
If cl = Empty Then
cl.EntireRow.Delete
End If
Next

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Easy Question

Select your data range and run this

Sub Button1_Click()
Dim i As Long
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
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

End Sub

"Posse John" wrote:

I need to check each row of a database to ensure it is not blank (this is
performed after importing data from an external source).

If the cell is blank, I need to delete the entire row.

The problem I'm having is if two blank rows are next to each other. The
routine I use does not delete the second row, because of the deletion of the
first one.

How do I 'reset' the variable to the row before the deletion, so that the
routine catches the second blank row?

For Each cl In Range("A2:A" & Range("A65500").End(xlUp).Row).Cells
If cl = Empty Then
cl.EntireRow.Delete
End If
Next

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Easy Question

Thank you both...didn't know about the 'specialcells' function. NICE.

Ended up using:
Columns("A:A").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete

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
Easy question M&M[_2_] Excel Discussion (Misc queries) 3 August 11th 07 07:00 AM
VBA help €“ an easy question MarkM Excel Programming 8 July 19th 06 08:40 PM
new user with easy question? not easy for me speakeztruth New Users to Excel 5 June 3rd 05 09:40 PM
easy question Dahlman Excel Worksheet Functions 3 April 1st 05 11:11 PM
Probably the most easy question here... JasonS[_2_] Excel Programming 1 October 8th 04 12:08 AM


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

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

About Us

"It's about Microsoft Excel"