Macro to delete lines below empty cell

ironsides

Well-known Member
Joined
Aug 12, 2002
Messages
575
Starts Cel A11

Entire Col A has either color no data or data no color or both

Macro needed that will delete all lines below the first cell in col A that it detects has no color or data.

and keeps the initial blank line.

or

Keep the lines and delete all data and color after it finds no entry in Col A (This is my preference)
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
See if this does what you want. I have assumed there will be at least one cell with no value before the last value cell or colour cell in column A

VBA Code:
Sub Clear_Cells()
  Dim c As Range
  
  For Each c In Columns("A").SpecialCells(xlBlanks)
    If c.Row > 10 And c.Interior.Color = 16777215 Then
      Rows(c.Row + 1 & ":" & FarRow).Clear
      Exit For
    End If
  Next c
End Sub
 
Upvote 0
Rows(c.Row + 1 & ":" & FarRow).Clear

Here I get a run-time error ('13')
Type Mismatch
 
Upvote 0
:oops: Ooops, I did a late edit to the code - but only part of it. Sorry. That line should be

VBA Code:
Rows(c.Row + 1 & ":" & Rows.Count).Clear
 
Upvote 0
Cheers. Thanks for the confirmation.
 
Upvote 0

Forum statistics

Threads
1,214,950
Messages
6,122,428
Members
449,083
Latest member
Ava19

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