Delete rows if cell is blank on a specific range.

p9j123

Active Member
Joined
Apr 15, 2014
Messages
288
Office Version
  1. 2013
Platform
  1. Windows
Hi Excel Gurus,

Can someone help me with a macro that will delete entire row if Cell on Column D is blank.

[Col D] [Col E] [Col F]
Row 12Row 12Row 12
Row 13Row 13Row 13
Row 14 Row 14
Row 15 Row 15
Row 16 Row 16
Row 17Row 17Row 17
Row 18Row 18
Row 19Row 19
Row 20
Row 21Row 21
Row 22Row 22Row 22
Row 23Row 23Row 23
Row 24Row 24
Row 25Row 25
Row 26Row 26
Row 27Row 27Row 27
Row 28Row 28
Row 29Row 29
Row 30Row 30Row 30

<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>
</tbody>

The macro should only read starting row 12 to row 20 only. Any blank cell on Column D beyond row 20 will be ignored.

In the illustration above, the macro should only delete rows 18 and 20
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
p9j123,

Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

1. Copy the below code
2. Open your NEW workbook
3. Press the keys ALT + F11 to open the Visual Basic Editor
4. Press the keys ALT + I to activate the Insert menu
5. Press M to insert a Standard Module
6. Where the cursor is flashing, paste the code
7. Press the keys ALT + Q to exit the Editor, and return to Excel
8. To run the macro from Excel press ALT + F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.

Code:
Sub DeleteBlankRows_D12_D20()
' hiker95, 04/19/2014, ME772227
On Error Resume Next
Range("D12:D20").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
On Error GoTo 0
End Sub

Before you use the macro with Excel 2007 or newer, save your workbook, Save As, a macro enabled workbook with the file extension .xlsm

Then run the DeleteBlankRows_D12_D20 macro.
 
Last edited:
Upvote 0
Hi,

Try:
Code:
Sub Macro1()
    Range("D12:D20").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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