Help with a "delete rows" Macro

  • Thread starter Thread starter NewUser22
  • Start date Start date
N

NewUser22

Hey guys, can anyone help me with a macro I just cannot get worked
out. I have a simple "delete Blank rows" Macro, however the "Blank"
cell is just the result of an "IF" function that returns a "" or blank
cell. However the cell still holds the equation so it is not deleting
the rows, even though they are blank (just not technically). I would
like to know how I can get the macro below (or any other ideas you may
have) to delete all the rows that return a False calculation due to an
IF function, that uses columns A-G as the search method. I have copied
my current macro below.

Sub Macro3()
'
' Macro3 Macro
' Macro recorded 4/20/2007 by fletchej
'
Columns("A:C").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
ActiveSheet.UsedRange

'
End Sub

Any explanation in a simplified form would be much appreciated,
sometimes I get lost in all the code.
 
One way:

Public Sub DeleteRowsWithBlanksInColumnsAthroughG()
Dim rDelete As Range
Dim rCell As Range

With ActiveSheet
For Each rCell In Intersect(.Columns(1), .UsedRange)
With rCell.Resize(1, 7)
If Application.CountIf(.Cells, vbNullString) > 0 Then
If rDelete Is Nothing Then
Set rDelete = .Cells
Else
Set rDelete = Union(rDelete, .Cells)
End If
End If
End With
Next rCell
If Not rDelete Is Nothing Then rDelete.EntireRow.Delete
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top