+ Reply to Thread
Results 1 to 3 of 3

Deleting the rows with no data

  1. #1
    Registered User
    Join Date
    04-09-2008
    Posts
    3

    Deleting the rows with no data

    Hi... I get files where some of the columns have data and some does not.... So i want to delete the rows which does not have any data....
    EX-A1 has data, C2 has data, B4 has data, A6 has data, and so on.....
    So I want to delete the row 3 as they don’t have any data.....
    How can i do this in Excel?
    Last edited by amehra; 04-09-2008 at 11:55 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Thread moved.

    Please post in the correct forum. If you want VBA, you want the Programming forum.

    Thanks.

  3. #3
    Registered User
    Join Date
    04-14-2008
    Location
    melbourne
    Posts
    2
    Try this code below. I am assuming that there are 10 rows by 6 columns of data. Modify to suit your requirement.

    Sub DelBlankRow()
    Dim NumbofRows As Integer, NumbColWithData As Integer
    Dim rgToEvaluate As Range
    Dim i As Integer, iDataStartRow As Integer
    Dim j As Integer, iEmptyCellCount As Integer

    NumbofRows = 10
    NumbColWithData = 6

    'Assuming the start row is row 1.
    iDataStartRow = 1
    Cells(NumbofRows, 1).Select

    'Start from the bottom up.
    For i = NumbofRows To iDataStartRow + 1 Step -1
    'On Error GoTo Exit_Sub

    iEmptyCellCount = 0
    For j = 1 To NumbColWithData
    If IsEmpty(Cells(ActiveCell.Row, j).Value) Then
    iEmptyCellCount = iEmptyCellCount + 1
    Else
    Exit For
    End If
    Next j

    If iEmptyCellCount = NumbColWithData Then
    ActiveCell.EntireRow.Delete
    End If
    ActiveCell.Offset(-1, 0).Select
    Next i
    Exit_Sub:
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1