Macro to delete specific rows with black cells

Apple08

Active Member
Joined
Nov 1, 2014
Messages
384
Hi All

I like to delete the rows for the range row 28 to row 45 if cells in column B are blank. Please could how can I write this macro? Thanks.
 

Some videos you may like

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,663
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Try this:
VBA Code:
Sub DeleteBlankRows()
For i = 45 To 28 Step -1
If Range("B" & i).Value = "" Then
Range("B" & i).EntireRow.Delete
End If
Next i
End Sub
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,005
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
If the cells are truly blank/empty then maybe...
VBA Code:
Sub Delblank()
On Error Resume Next
Range("B28:B45").SpecialCells(4).EntireRow.Delete
End Sub
 
Solution

Apple08

Active Member
Joined
Nov 1, 2014
Messages
384
Thank you so much, both of the macros work but the speed of the latter one is quicker. Many thanks both!
 

maabadi

Well-known Member
Joined
Oct 22, 2012
Messages
1,663
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
You're Welcome & Thanks for feedback.
AND you should Mark The Post give to You Best answer (here Post #3) Not Yours. :unsure:
 

Watch MrExcel Video

Forum statistics

Threads
1,127,905
Messages
5,627,572
Members
416,255
Latest member
amethystia

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
Top