Delete blank rows, with a few exceptions [VBA]

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
151
Office Version
  1. 2016
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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,664
Office Version
  1. 365
Platform
  1. Windows
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
 
Solution

Martin_H

Board Regular
Joined
Aug 26, 2020
Messages
151
Office Version
  1. 2016
Platform
  1. Windows
Solved! Awesome as always.

Thank you Fluff! Much appreciated.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
65,664
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,147,635
Messages
5,742,244
Members
423,717
Latest member
rubthenut

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