Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default delete all rows above a selected cell


I have a macro that selects a specific (and different in each worksheet)
cell based on cell contents. From that cell location (it is the
activated cell at current step of macro) I want to highlight and delete
all rows in the worksheet above to the top of the worksheet. I'm stuck.
Any ideas?


--
rroach
------------------------------------------------------------------------
rroach's Profile: http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=378687

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default delete all rows above a selected cell

Sub DeleteAbove()
Dim rng As Range

On Error Resume Next
Set rng = ActiveCell.Offset(-1, 0)
On Error GoTo 0
If Not rng Is Nothing Then _
Range("A1", ActiveCell.Offset(-1, 0)).EntireRow.Delete
End Sub

--
HTH...

Jim Thomlinson


"rroach" wrote:


I have a macro that selects a specific (and different in each worksheet)
cell based on cell contents. From that cell location (it is the
activated cell at current step of macro) I want to highlight and delete
all rows in the worksheet above to the top of the worksheet. I'm stuck.
Any ideas?


--
rroach
------------------------------------------------------------------------
rroach's Profile: http://www.excelforum.com/member.php...o&userid=21093
View this thread: http://www.excelforum.com/showthread...hreadid=378687


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default delete all rows above a selected cell

If no blank cells above the active cell........

Sub SelectUp()
Range(ActiveCell, ActiveCell.End(xlUp)).EntireRow.Delete
End Sub

Otherwise.....

Sub SelectUp()
Range(ActiveCell, Range("A1")).EntireRow.Delete
End Sub


Gord Dibben Excel MVP


On Mon, 13 Jun 2005 16:11:27 -0500, rroach
wrote:


I have a macro that selects a specific (and different in each worksheet)
cell based on cell contents. From that cell location (it is the
activated cell at current step of macro) I want to highlight and delete
all rows in the worksheet above to the top of the worksheet. I'm stuck.
Any ideas?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete selected rows data Pat Excel Programming 1 January 24th 05 04:02 PM
Delete non-selected rows SparePersn Excel Programming 2 December 21st 04 02:57 PM
Delete Selected Rows Ken[_18_] Excel Programming 2 February 5th 04 10:33 PM
Need a macro to delete selected rows RKettle Excel Programming 5 January 13th 04 05:29 PM
Delete/Collapse Rows Not Selected Cindy Excel Programming 19 November 21st 03 03:38 AM


All times are GMT +1. The time now is 09:21 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"