Find Lastcell in Column and delete rows above with blanc cells in that column

  • Hello,


    I found a function that founds the last used cell in a column.



    Now I need to delete all the rows above that row with a blanc cell in that column.


    So the macro must find the last cell in a column, and then delete all the rows above that have a blanc cell in this column.


    Can somebody help?


    Grtz


    aisietie

  • Re: Find Lastcell in Column and delete rows above with blanc cells in that column


    I doubt that code will work. You can use something like this:

    Code
    Function x(c As Long)
    
    
    With Sheets("Sheet1")
        .Range(.Cells(1, c), .Cells(Rows.Count, c).End(xlUp)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    End With
    
    
    End Function
  • Re: Find Lastcell in Column and delete rows above with blanc cells in that column


    Thx for the reply.


    But is it possible to let it work with a commandbutton click?


    Can this function be implemented in the commandbutton click event?


    aisietie

  • Re: Find Lastcell in Column and delete rows above with blanc cells in that column


    OK, how can I let this or another function do the thing?


    aisietie

  • Re: Find Lastcell in Column and delete rows above with blanc cells in that column


    When do you want it to do its thing? If you assign it to a button, how does it know which column to work on? You could have an input box in which the column is entered and then the code runs. Or assign it to run when a cell in the column is double-clicked?

  • Re: Find Lastcell in Column and delete rows above with blanc cells in that column


    At this moment I have a button that cut a row and paste the row in an other sheet.

    Code
    Sheets("Input").Range("A" & ComboBox1.ListIndex + 3 & ":ZZ" & ComboBox1.ListIndex + 3).Cut Destination:=Worksheets(strWs).Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)


    I would like, that after the cut, the empty row is deleted.
    So i thought by checking if there is an empty cell in column A, then delete this row.


    aisietie

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!