ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to delete specific rows above selected cell (https://www.excelbanter.com/excel-programming/371446-macro-delete-specific-rows-above-selected-cell.html)

[email protected]

Macro to delete specific rows above selected cell
 
Hello,

I am trying to write the following macro, but I can't seem to get it
right.
I've had a look around on the other posts but I cant find anything to
suit.

I am using Excel 2002.

The macro contains other elements which I have sucessfully programmed.
At this point in the macro, a specific cell has been selected, and I
need to delete two specific rows which are above this cell.

A practical example would be, supposing Cell A10 has been selected as
the selected cell, the macro must now delete Rows 7 and 8 only, leaving
Rows 1-6 and 9-10 as they are.

If anybody can assist with this it would be much appreciated.

Many thanks.

Richard.


Gary Keramidas

Macro to delete specific rows above selected cell
 
one way if a10 is selected

ActiveCell.Offset(-3, 0).Resize(2, 1).EntireRow.Delete

--


Gary


wrote in message
oups.com...
Hello,

I am trying to write the following macro, but I can't seem to get it
right.
I've had a look around on the other posts but I cant find anything to
suit.

I am using Excel 2002.

The macro contains other elements which I have sucessfully programmed.
At this point in the macro, a specific cell has been selected, and I
need to delete two specific rows which are above this cell.

A practical example would be, supposing Cell A10 has been selected as
the selected cell, the macro must now delete Rows 7 and 8 only, leaving
Rows 1-6 and 9-10 as they are.

If anybody can assist with this it would be much appreciated.

Many thanks.

Richard.




Die_Another_Day

Macro to delete specific rows above selected cell
 
Rows(ActiveCell.Row - 3 & ":" & ActiveCell.Row - 2).Delete

HTH

Charles

wrote:
Hello,

I am trying to write the following macro, but I can't seem to get it
right.
I've had a look around on the other posts but I cant find anything to
suit.

I am using Excel 2002.

The macro contains other elements which I have sucessfully programmed.
At this point in the macro, a specific cell has been selected, and I
need to delete two specific rows which are above this cell.

A practical example would be, supposing Cell A10 has been selected as
the selected cell, the macro must now delete Rows 7 and 8 only, leaving
Rows 1-6 and 9-10 as they are.

If anybody can assist with this it would be much appreciated.

Many thanks.

Richard.



[email protected]

Macro to delete specific rows above selected cell
 
Thank you both for your help on this, much appreciated.



All times are GMT +1. The time now is 01:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com