locked
Clear all cells in row if first cell in row is cleared RRS feed

  • Question

  • Is there any way in which i can get all the cells in a row to be automatically cleared if the first cell in that row is cleared?

     

    Thursday, July 7, 2011 10:21 AM

Answers

  • Hi

    Manually

    Click the row number to the left of the empty cell in column A, and press Delete.

    Automatically

    You'll need a macro that checks the cell contents in each cell in column A and does the same when the cell is empty.  Something like:

     

        Dim LastRow As Long
       
        Range("A1").Activate
        LastRow = Range("A" & Rows.Count).End(xlUp).Offset(1).Row
       
        Do While ActiveCell.Row < LastRow
            If ActiveCell.Value = "" Then
                ActiveCell.EntireRow.Delete
                LastRow = LastRow - 1
            Else
                ActiveCell.Offset(1, 0).Activate
            End If
        Loop

    Hope this helps


    G North MMI
    Thursday, July 7, 2011 10:47 AM