I have a “names” sheet that I update or delete names from (all in a single column). I have a macro that I run after I delete or add a new name, will copy and paste the names to “another sheet” (for tracking purposes) and than sorts the list of names.
When I run the macro, it all works well. However, is my only issue when I delete a name, that other data that was associated stays behind (I have to delete myself afterwards).
Is there a piece of code that could check if names column is blank, delete data from previous column, same row?
For example:
Macro copies names to D6:D165. Every name in the list has data associated to it in the previous columns/rows (A6:A165, B6:B165 and C6:165). Once the macro runs, have the code check if there are any empty cells in D6:D165, if so, delete any data to only the columns/rows that correspond to the empty cells.
If D130 is empty, delete A130, B130 and C130.
Hello Rz6657,
Try this macro. You change the starting row which is set to 6, if you need to. The last row in column "D" is found automatically.
Sincerely,Sub DeleteEmptyRows() Dim LastRow As Long Dim R As Long Dim StartRow As Long StartRow = 6 LastRow = Cells(Rows.Count, "D").End(xlUp).Row For R = LastRow To StartRow Step -1 If Cells(R, "D").Value = "" Then Cells(R, "D").EntireRow.Delete End If Next R End Sub
Leith Ross
Thanks for the reply. I have a question about your code. I have formulas in the other consecutive columns. Will your code delete my formulas also, since it says delete entire row.. ? (the only cells that don't have formulas are columns A, B C...
Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks