#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 91
Default Delete 3 end row

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Delete 3 end row

Hi,

This will clear the last 3 rows of the active sheet. Note I the on error
line is to cope when there are less than 3 rows on the sheet

Sub del_Last_3()
Dim LastRow As Long
On Error Resume Next
LastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
ActiveSheet.Rows(LastRow - 2 & ":" & LastRow).ClearContents
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"climate" wrote:

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Delete 3 end row

another way

ActiveSheet.Rows(LastRow - 2).Resize(3).ClearContents
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Mike H" wrote:

Hi,

This will clear the last 3 rows of the active sheet. Note I the on error
line is to cope when there are less than 3 rows on the sheet

Sub del_Last_3()
Dim LastRow As Long
On Error Resume Next
LastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
ActiveSheet.Rows(LastRow - 2 & ":" & LastRow).ClearContents
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"climate" wrote:

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 91
Default Delete 3 end row

Hello Mike
Thank you very much.
Ok
Best regards

"Mike H" wrote:

Hi,

This will clear the last 3 rows of the active sheet. Note I the on error
line is to cope when there are less than 3 rows on the sheet

Sub del_Last_3()
Dim LastRow As Long
On Error Resume Next
LastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
ActiveSheet.Rows(LastRow - 2 & ":" & LastRow).ClearContents
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"climate" wrote:

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Delete 3 end row

Your welcome

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"climate" wrote:

Hello Mike
Thank you very much.
Ok
Best regards

"Mike H" wrote:

Hi,

This will clear the last 3 rows of the active sheet. Note I the on error
line is to cope when there are less than 3 rows on the sheet

Sub del_Last_3()
Dim LastRow As Long
On Error Resume Next
LastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
ActiveSheet.Rows(LastRow - 2 & ":" & LastRow).ClearContents
End Sub
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"climate" wrote:

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's



  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Delete 3 end row

If you are looking for a macro to delete the last 3 rows try the below

Sub MyMacro()
Dim lngLastRow As Long

lngLastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row
Rows(lngLastRow).Offset(-2).Resize(3).Select
End Sub

--
Jacob (MVP - Excel)


"climate" wrote:

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's

  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,520
Default Delete 3 end row

Oops...Missed to delete..

Sub MyMacro()
Dim lngLastRow As Long

lngLastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row
Rows(lngLastRow).Offset(-2).Resize(3).Delete
End Sub

--
Jacob (MVP - Excel)


"climate" wrote:

Hi
I want to delete three end row of any sheet. any sheet has different row
number.
Thank's for any help.

your's

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 the test values, but do not delete the formulas kathy Excel Discussion (Misc queries) 1 February 21st 07 07:03 PM
How to Delete a Range in Closed Workbook (to Replace Delete Query) [email protected] Excel Discussion (Misc queries) 1 March 8th 06 10:10 AM
How do i delete a macro in Excel 2003 when delete isn't highlight Abel Excel Discussion (Misc queries) 2 September 13th 05 04:09 AM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM


All times are GMT +1. The time now is 06:50 PM.

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

About Us

"It's about Microsoft Excel"