Avatar of Rama Tito
Rama Tito
Flag 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

Microsoft Excel

Avatar of undefined
Last Comment
Martin Liss

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Saqib Husain

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Saqib Husain

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
Anuradha Goli

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck