View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
ILoveMyCorgi ILoveMyCorgi is offline
external usenet poster
 
Posts: 55
Default Can someone help me?

Thank you... it did not work. I still had rows with data in columns A
through D and no data in columns E through J are empty yet the rows have not
been deleted.

"Mike H" wrote:

Hi,

How about this

Sub Delete_Rows()
Set sht = Sheets("Sheet1")'Change to suit
lastrow = sht.Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = sht.Range("A1:A" & lastrow)
For Each c In MyRange
If WorksheetFunction.CountA(c.Offset(, 5).Resize(, 5)) = 0 Then
c.EntireRow.Delete
End If
Next
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"ILoveMyCorgi" wrote:

I have an Excel spreadsheet with 10 columns. If columns 5 through 10 are
empty, I want to delete the entire row and move on to the end of my
spreadsheet. Is there a function or an easy Visual Basic macro I can run to
accomplish this task? Thanks in advance for your help... I do not know what
I'd do without this resource!