LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Delete Multiple Rows in one go

Hi Chip,
I am having another go at this.
I have modified your code slightly:

Sub AAA()
Const WHAT_COLUMN = "k"
Dim LastCell As Range
Dim FoundCell As Range

Set FoundCell = ActiveSheet.UsedRange.Find("k")
If FoundCell Is Nothing Then
' not found. get out.
Exit Sub
End If
With ActiveSheet
Set LastCell = .Cells(.Rows.count, WHAT_COLUMN).End(xlUp)
.Range(FoundCell(2000, 1), LastCell).EntireRow.Delete
End With
End Sub

It works appart from it deletes the last row of data.
Is there some sort of an offset (Have I got that right) so that it wont
delete the last so many rows below the last value (10 rows for example)?

Many thanks

John





"Chip Pearson" wrote:

Try something like the following:

Sub AAA()
Const WHAT_COLUMN = "A"
Dim LastCell As Range
Dim FoundCell As Range

Set FoundCell = ActiveSheet.UsedRange.Find("abc")
If FoundCell Is Nothing Then
' not found. get out.
Exit Sub
End If
With ActiveSheet
Set LastCell = .Cells(.Rows.Count, WHAT_COLUMN).End(xlUp)
.Range(FoundCell(11, 1), LastCell).EntireRow.Delete
End With
End Sub

Change WHAT_COLUMN to the column in which the specified value ("abc"
in this example) is to be found.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Wed, 14 Jan 2009 10:15:01 -0800, JohnUK
wrote:

Hi, Can anyone help with this. I need a piece of code that can delete all
rows in one swoop, working from the last/end row to the 10th row below a
given column with values in it. I hope I explained that okay. Help greatly
appreciated
John




 
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
Hpw do I delete multiple empty rows found between filled rows? Bill Excel Worksheet Functions 2 November 15th 09 07:12 PM
Delete all rows below certain value on multiple worksheets? [email protected] Excel Discussion (Misc queries) 1 January 4th 08 05:51 PM
Delete multiple rows PJ Usher Excel Programming 2 September 20th 07 04:05 PM
Delete Blank Rows Code - Multiple Worksheets - Multiple Documents BenS Excel Discussion (Misc queries) 3 June 29th 07 12:20 AM
Delete multiple rows Steph[_3_] Excel Programming 1 January 28th 04 04:31 PM


All times are GMT +1. The time now is 08:11 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"