Solved

macro to delete blank empty row set data range

Posted on 2014-01-16
3
639 Views
Last Modified: 2014-01-17
Hi Expert's excel 2007

(starting point a2) and data range a2:g15000 to across columns and rows a2: and delete th3 entire row where the cell are either empty or blank.
0
Comment
Question by:route217
  • 2
3 Comments
 
LVL 26

Expert Comment

by:MacroShadow
ID: 39784827
I'm sorry your question isn't clear please rephrase it.

Do you want to delete the rows only if all cells in the row are blank or also if only one of them is blank?
0
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39784834
Sub DeleteBlankRows1()

'Deletes the entire row within the selection if the ENTIRE row contains no data.

    Dim rng As Range
    Dim i As Long

    Set rng = Range("A2:G15000")

    With Application
        .Calculation = xlCalculationManual
        .ScreenUpdating = False

        For i = rng.Rows.Count To 1 Step -1
            If WorksheetFunction.CountA(rng.Rows(i)) = 0 Then
                rng.Rows(i).EntireRow.Delete
            End If
        Next i

        .Calculation = xlCalculationAutomatic
        .ScreenUpdating = True
    End With

End Sub

Sub DeleteBlankRows2()

    'Deletes the entire row within the range if SOME of the cells within the range contain no data

    Dim rng As Range
    
    Set rng = Range("A2:G15000")
    On Error Resume Next
    rng.EntireRow.SpecialCells(xlBlanks).EntireRow.Delete
    On Error GoTo 0

End Sub

Open in new window

0
 

Author Comment

by:route217
ID: 39785755
Thanks for the feedback and apologies for the late reply. ..internet problems.

Let me test.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now