Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select last n rows and delete?
I've done a search and nothing quite seems to fit. Basically I merely
want to select the last /n/ rows in a certain column and then delete those entire rows. n being four for the forseeable future. It started looking like this: //--- Range("B" & Rows.Count).End(xlUp).Select Selection.Offset(RowOffset:=-3).Select //--- But anything after doesn't do what I'd want. I appreciate a suggestion. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select last n rows and delete?
Hi JD,
Try: '============= Public Sub TesterD() Dim n As Long n = 4 Cells(Rows.Count, "B").End(xlUp).Offset(n - 1).Resize(n).Delete End Sub '<<============= --- Regards, Norman "JD" wrote in message ups.com... I've done a search and nothing quite seems to fit. Basically I merely want to select the last /n/ rows in a certain column and then delete those entire rows. n being four for the forseeable future. It started looking like this: //--- Range("B" & Rows.Count).End(xlUp).Select Selection.Offset(RowOffset:=-3).Select //--- But anything after doesn't do what I'd want. I appreciate a suggestion. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select last n rows and delete?
Hi JD,
Correcting, try: '============= Public Sub TesterD() Dim n As Long n = 4 Cells(Rows.Count, "B").End(xlUp).Offset(1 - n). _ Resize(n).EntireRow.Delete End Sub '<<============= -- Regards, Norman |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select last n rows and delete?
Norman Jones wrote:
Hi JD, Correcting, try: '============= Public Sub TesterD() Dim n As Long n = 4 Cells(Rows.Count, "B").End(xlUp).Offset(1 - n). _ Resize(n).EntireRow.Delete End Sub '<<============= That one works perfectly, thanks. Question; the resize works as a range because the variable n has been declared? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Select last n rows and delete?
Hi JD,
That one works perfectly, thanks. Question; the resize works as a range because the variable n has been declared? The Resize Property returns a resized range. The syntax for Resize is RangeExpression(RowSize, ColumnSize). The suggested code uses an abbreviated form, Resize(n), which leaves the ColumnSize of the range unchanged. --- Regards, Norman "JD" wrote in message oups.com... Norman Jones wrote: Hi JD, Correcting, try: '============= Public Sub TesterD() Dim n As Long n = 4 Cells(Rows.Count, "B").End(xlUp).Offset(1 - n). _ Resize(n).EntireRow.Delete End Sub '<<============= That one works perfectly, thanks. Question; the resize works as a range because the variable n has been declared? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Select a range of rows to delete | Excel Worksheet Functions | |||
select and delete specific rows | Excel Discussion (Misc queries) | |||
select and delete all blank rows | Excel Discussion (Misc queries) | |||
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below | Excel Programming | |||
Select certain rows of sheet & delete the rest | Excel Programming |