View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How to del last two rows

Can you pick out a column that would be used to determine that last used row?

Dim LastRow as long
with worksheets("sheet9999")
lastrow = .cells(.rows.count,"A").end(xlup).row
if lastrow 1 then
.rows(lastrow-1).resize(2).delete
end if
end with

I used column A to determine that last used row.

Johnny wrote:

the last 2 rows that I want to del is not the last two rows of the worksheet.
the last 2 rows I want to del is in my report, sometime the last two rows at
row 258 and 259. or 158,159, or 236,237.

"jlclyde" wrote:

On Nov 20, 12:39 pm, Johnny wrote:
Hi Guys.
It dosn't matter how many row in the worksheet.
how to create a formula or macro to del only the last two rows.


All worksheets have the same number of rows. If you want to delete
rows 65536 and 65535 that is a simple macro.
Sub Deletelast2rows()

Range("A65535", "IV65536").Delete

End Sub
If you want the last two rows that have something in them then that is
a little trickier.

You will use End(xl(up)
Jay


--

Dave Peterson