Delete blank rows, with a few exceptions [VBA]

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
190
Office Version
  1. 365
Platform
  1. Windows
Hello folks,

I am looking for a help with a VBA Macro.

I have a Worksheet with approximately 260 rows and I want a Macro that will delete all blank rows based on a cell value in the column A.

Rows starting from 1 to 13 should be untouched.

Macro should work only for rows starting from 14 to 257.

In every cell, in column A, starting from row 14 to 257 there is a formula:

VBA Code:
=IF(N14="";"";$F$2)

For example if the cell A26 has a "" value (a blank value), I want that row to be deleted.
If the cell A26 is filled with some non-blank value, I want to keep that row.

Help is much appreciated.


Thank you!
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How about
VBA Code:
Sub MartinH()
   Dim Cl As Range, Rng As Range
   
   For Each Cl In Range("A14:A257")
      If Cl.Value = "" Then
         If Rng Is Nothing Then Set Rng = Cl Else Set Rng = Union(Rng, Cl)
      End If
   Next Cl
   If Not Rng Is Nothing Then Rng.EntireRow.Delete
End Sub
 
Upvote 0
Solution
Solved! Awesome as always.

Thank you Fluff! Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,974
Messages
6,122,536
Members
449,088
Latest member
RandomExceller01

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