Link to home
Start Free TrialLog in
Avatar of Rama Tito
Rama TitoFlag for Malaysia

asked on

Delete empty row

Hi, I am calling this function from sheet1 to execute in sheet3 but its executing in sheet1. Please do advice
Sub DeleteEmptyRows()
    Dim LastRow As Long
    Dim r As Long
    
    LastRow = Sheet3.UsedRange.Row - 1 + Sheet3.UsedRange.Rows.Count
    Application.ScreenUpdating = False
    For r = LastRow To 1 Step -1
        If Sheet3.Application.WorksheetFunction.CountA(Rows(r)) = 0 _
          Then Rows(r).Delete
        
    Next r
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Saqib Husain
Saqib Husain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In fact


        If Sheet3.Application.WorksheetFunction.CountA(Rows(r)) = 0 _
          Then Rows(r).Delete

should be


        If Sheet3.Application.WorksheetFunction.CountA(sheet3.Rows(r)) = 0 _
          Then sheet3.Rows(r).Delete
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial