Solved

macro to delete blank empty row set data range

Posted on 2014-01-16
3
683 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

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 27

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

733 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