Delete Row, when both cells are empty

hjason315

New Member
Joined
Jul 11, 2011
Messages
19
I need some help with macro.

I would like to delete all rows when BOTH cells in row J AND row K are empty. Can anyone help me with that!

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
if there is no gap in column A try this macro test in copy of the file and not in the original file

Code:
Sub test()
Dim j As Integer
For j = Range("A1").End(xlDown).Row To 1 Step -1
If Cells(j, "J") = "" And Cells(j, "K") = "" Then Cells(j, "J").EntireRow.Delete
Next j
End Sub
 
Upvote 0
Thanks for helping, but I think there's something wrong with the code, it only deletes the first row then stop. What do you mean by gap in column A? does it mean every cell in column A has to be filled?
 
Upvote 0
Code:
[COLOR="Blue"]Sub[/COLOR] test()
    [COLOR="Blue"]Dim[/COLOR] j [COLOR="Blue"]As[/COLOR] [COLOR="Blue"]Integer[/COLOR]
    [COLOR="Blue"]For[/COLOR] j = Cells(Rows.count, "A").End(xlUp).Row [COLOR="Blue"]To[/COLOR] 1 [COLOR="Blue"]Step[/COLOR] -1
        [COLOR="Blue"]If[/COLOR] sempty(Cells(j, "J")) [COLOR="Blue"]And[/COLOR] IsEmpty(Cells(j, "K")) [COLOR="Blue"]Then[/COLOR] Cells(j, "J").EntireRow.Delete
    [COLOR="Blue"]Next[/COLOR]
[COLOR="Blue"]End[/COLOR] [COLOR="Blue"]Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,522
Messages
6,179,292
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top