Delele Blank Rows

RGButzArchInc

New Member
Joined
Aug 16, 2009
Messages
24
I reworking a spreadsheet in an address book format. I want to check if cell(i,1) and cell(I5) are empty. if empty I want to delete the row. VBA and Macros 2010 shows a sub routine on pages 73 and 74 listed as follows.

LastRow = cells(rows.coutn,1).End(xlUp).roe

for i = 1 to lastRow
if IsEmptyh(cells(1,1)) Then
Cells(i,1).Resize(1,4).Interior.ColorIndex = 1
end if
Next i

I have written the following

Sub F_DeleteEmptyDate_06()
'
' DeleteEmptyDate Macro
' Delete the rows that have an empty date cell and an empty address cell.
' The end of the data is determined by inspection
'
'Last Row is determined by inspection
'Declare Variables
Dim I As Integer
Dim Cell As Range
Dim ws As Worksheet

'Set variables
Set ws = ActiveSheet
Set Cell = Cells.Columns(WScolAddress)

'Executables


For I = 1 To 13074
If IsEmpty(Cells(I, WScolAddress)) And _
IsEmpty(Cells(I, 5)) Then
'ActiveCell.Offset(2, 0).Rows("1:1").EntireRow.Select
ActiveCell.EntireRow.Select
Selection.Delete Shift:=xlUp
'Application.Goto Reference:="DeleteEmptyDate"
End If
Next

End Sub

Where am I going wrong
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
When deleting rows (or columns), you have to loop backwards through the data, otherwise it skips over data.

Try:

Code:
Public Sub DeleteRows()
Dim i   As Long, _
    LR  As Long
    
LR = Range("A" & Rows.Count).End(xlUp).Row
Application.ScreenUpdating = False
For i = LR To 1 Step -1
    Application.StatusBar = i & " rows left to check."
    If Cells(i, 1).Value = "" And Cells(i, 5).Value = "" Then
        Rows(i).Delete
    End If
Next i
Application.ScreenUpdating = True
Application.StatusBar = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top