delete last-line help.

M

Matthew Dyer

I have a code that will delete the last line of a spreadsheet -

Range("a65536").End(xlUp).Select
Selection.EntireRow.Delete

What I'd like it to do is look into that line, and if the value for
the cell in column A is MTD_AVG to delete the line, but if it is
anything else to leave the line intact. Help please?
 
J

Jim Cone

With Cells(Rows.Count, 1).End(xlUp)
If InStr(1, .Value, "MTD_AVG", vbBinaryCompare) > 0 Then
.EntireRow.Delete
End If
End With
--
Jim Cone
Portland, Oregon USA
Review: http://www.contextures.com/excel-sort-addin.html

..
..
..

"Matthew Dyer" <[email protected]>
wrote in message
I have a code that will delete the last line of a spreadsheet -
Range("a65536").End(xlUp).Select
Selection.EntireRow.Delete

What I'd like it to do is look into that line, and if the value for
the cell in column A is MTD_AVG to delete the line, but if it is
anything else to leave the line intact. Help please?
 
M

Matthew Dyer

With Cells(Rows.Count, 1).End(xlUp)
  If InStr(1, .Value, "MTD_AVG", vbBinaryCompare) > 0 Then
    .EntireRow.Delete
  End If
End With
--
Jim Cone
Portland, Oregon  USA
Review:  http://www.contextures.com/excel-sort-addin.html

.
.
.

"Matthew Dyer" <[email protected]>
wrote in message
I have a code that will delete the last line of a spreadsheet -
Range("a65536").End(xlUp).Select
Selection.EntireRow.Delete

What I'd like it to do is look into that line, and if the value for
the cell in column A is MTD_AVG to delete the line, but if it is
anything else to leave the line intact. Help please?

works PERFECTLY! Thanks for the quick response!
 

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

Top