Delete Rows with range of empty cells

ssgmiami

New Member
Joined
Nov 12, 2007
Messages
22
I have a large spreadsheet comprised of a variable number of rows. All rows have data in Columns 1 thru 3. Columns 4 thru n should contain data, but some do not. I need to delete any row that is empty from column 4 thru n. The number of columns can be determined from the header in row 1.

Any help is greatly appreciated.

SSGMiami
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Try...

<font face=Calibri><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN><br><br><SPAN style="color:#00007F">Sub</SPAN> test()<br><br>    <SPAN style="color:#00007F">Dim</SPAN> LastRow <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> LastColumn <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> i <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    Application.ScreenUpdating = <SPAN style="color:#00007F">False</SPAN><br>    <br>    LastRow = Cells(Rows.Count, "A").End(xlUp).Row<br>    LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column<br>    <br>    <SPAN style="color:#00007F">For</SPAN> i = LastRow <SPAN style="color:#00007F">To</SPAN> 2 <SPAN style="color:#00007F">Step</SPAN> -1<br>        <SPAN style="color:#00007F">If</SPAN> Application.CountA(Range(Cells(i, "D"), Cells(i, LastColumn))) = 0 <SPAN style="color:#00007F">Then</SPAN><br>            Rows(i).Delete<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> i<br>    <br>    Application.ScreenUpdating = <SPAN style="color:#00007F">True</SPAN><br>    <br>    MsgBox "Completed...", vbInformation<br>    <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0
Dominic,

I won't be able to try this on live data until I am back at work on Monday, but it looks like it will work for what I need. I was attempting a very similar solution, but just couldn't get the syntax right with the CountA function. I wasn't using the Application. syntax as in your statement

If Application.CountA(Range(Cells(i, "D"), Cells(i, LastColumn))) = 0

I think you've got it right! I will let you know.

Thanks,
John
 
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,879
Members
452,948
Latest member
Dupuhini

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