LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Rows based on number of instances

Guy,

We are confused. If Tom's method was too slow, then my macro, which was
essentially the same as Tom's in VBA form, would also be too slow, but this
method is magnitudes slower. Why do you want to pursue this method, why not
get our suggestion working?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Guy Brown via OfficeKB.com" wrote in message
...
Tom,

you are absolutely right. I have created my own script which does almost
what I want apart from the fact that the loop, as you say, does not take
into account the deleted rows?

"Private Sub CommandButton1_Click()
Const nThreshold As Long = 400
Dim cLastRow As Long

Dim myRng As Range
Dim C, s, v, vnext
Dim count As Integer, nr As Long, z As Integer, totalcount As Integer,
newcount As Integer
With Worksheets(1)
Set myRng = .Range("C1", .Cells(.Rows.count, "C").End(xlUp))
End With
nr = myRng.Rows.count
count = 0
For s = 1 To nr + 1
Cells(s, 3).Select
v = Cells(s, 3).Value
vnext = Cells(s + 1, 3).Value
If v = vnext Then
count = count + 1
ElseIf v < vnext Then
If count 20 Then
Range(Cells(s - count, 3), Cells(s, 3)).Select
Selection.EntireRow.Delete
totalcount = (count + 1) + oldcount
oldcount = totalcount
count = 0

Else
count = 0
End If
End If
Next s

MsgBox totalcount & " Records have been deleted", , "Deleted Record Count"

End Sub"

How can I do this??

otherwise I could "Clear" the rows and then delete all blank rows - any
idea how I can do this?

--
Message posted via http://www.officekb.com



 
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 Rows based on condition Vic Excel Discussion (Misc queries) 2 August 18th 09 08:54 PM
Delete Rows based on value Sabosis Excel Worksheet Functions 4 October 28th 08 11:21 PM
Delete rows based on certain criteria Coal Miner Excel Discussion (Misc queries) 2 March 3rd 06 05:56 PM
Delete Rows Based On Content halem2[_39_] Excel Programming 0 October 12th 04 03:27 PM
Delete Rows Based On Content halem2[_38_] Excel Programming 1 October 12th 04 03:16 PM


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