Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

selection help

  Asked By: Bakir    Date: Mar 04    Category: MS Office    Views: 514
  

Ive got a table of 20 rows (row numbers vary). i need to select the
last 10 rows (fixed amount) of data and delete all above it.

ive used

x = UsedRange.Rows.Count
y = totalrows - 10

but when i try

Rows("1:y").Select

to select the rows above the 10 i need it brings up an error, but if
i were to replace the "y" with a row number it works fine, ie Rows
("1:5").select.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Anna Hill     Answered On: Mar 04

You might try this (untested by no reason why it wouldn't work):

Rows("1:" & y).Select

 
Answer #2    Answered By: Alexander Fields     Answered On: Mar 04

this *might* work:

y = (Cells.SpecialCells(xlCellTypeLastCell).row - 10)

 
Answer #3    Answered By: Vivian Ruiz     Answered On: Mar 04

Steve, here is a one line command which deletes all rows  above the last 10:

Range(Cells(1, 1), Cells(ActiveSheet.UsedRange.Rows.Count - 10,
1)).EntireRow.Delete

 
Didn't find what you were looking for? Find more on selection help Or get search suggestion and latest updates.




Tagged: