View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Need a macro to delete rows

empty... rows 45 through 233 contain data... the trick is that the rows that
i say are empty are not truely empty, but contain link formulas that return
"" ...nothing...


That's not a trick it's completely different to what you said first time :)
Try this

Sub marine()
Dim myrange as range, myrange1 As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A3:A" & lastrow)
For Each c In myrange
If c.Value = "" Then
If myrange1 Is Nothing Then
Set myrange1 = c.EntireRow
Else
Set myrange1 = Union(myrange1, c.EntireRow)
End If
End If
Next
myrange1.EntireRow.Delete
End Sub


Mike


"jmr4h8" wrote:

This deletes all data in my sheet except for the first 2 rows.

the set up is this... the first 2 rows contain headers.... then there is a
gap of 40 or so rows before the data begins. so rows 3 through 44 are
empty... rows 45 through 233 contain data... the trick is that the rows that
i say are empty are not truely empty, but contain link formulas that return
"" ...nothing... depending on the conditions. What I need is rid the gap so
that what is in row 45 is now in row 3 and row 46 is in row 4 and so on. im
not sure if its possible what do you think?

"Mike H" wrote:

Try

Sub marine()
lastrow = Range("A3").End(xlDown).Row
Range("A3:A" & lastrow - 1).EntireRow.ClearContents
End Sub

Mike

"jmr4h8" wrote:

I need to find the first data occurance in column D and delete all rows above
it except rows 1 and 2.