Basically, you have to define the range of cells from LastRow -1 to Lastrow + 2
Range("A" & LastRow - 1 & ":A" & LastRow + 2).
Then, reference the entire rows by using ".EntireRow"
then tell it what you want to do with it (.Delete)
and you end up with:
Range("A" & LastRow - 1 & ":A" & LastRow + 2).EntireRow.Delete
Paul
-----------------------------------------
"Do all the good you can,
By all the means you can,
In all the ways you can,
In all the places you can,
At all the times you can,
To all the people you can,
As long as ever you can." - John Wesley
-----------------------------------------
________________________________
From: Manny mgarza@fellowes.com>
To: ExcelVBA@yahoogroups.com
Sent: Thu, January 3, 2013 12:36:55 PM
Subject: [ExcelVBA] Delete rows relative to Range.End(xlDown).Row
I want to delete rows in my spreadsheet relative to the last row returned using
this statement: LastRow = Worksheets("Sheet1").Range("A2").End(xlDown).Row
Specifically there will be 2 rows after LastRow that I want to delete and 1 row
before LastRow that I want to delete. What code would do this?
I hope I've given enough info but if not ask and I will fill in details.
Thanks! You guys are awesome.
[Non-text portions of this message have been removed]
Reply via web post | Reply to sender | Reply to group | Start a New Topic | Messages in this topic (2) |
Be sure to check out TechTrax Ezine for many, free Excel VBA articles! Go here: http://www.mousetrax.com/techtrax to enter the ezine, then search the ARCHIVES for EXCEL VBA.
----------------------------------
Visit our ExcelVBA group home page for more info and support files:
http://groups.yahoo.com/group/ExcelVBA
----------------------------------
More free tutorials and resources available at:
http://www.mousetrax.com
----------------------------------
Tidak ada komentar:
Posting Komentar