View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Alex J Alex J is offline
external usenet poster
 
Posts: 85
Default Snailspace Macro Needs Rejuvenation....Anyone?

adidas,
You can try creating a union of all the rows to delete, and then delete just
1 time. The trick is to sort or filter all the "0" rows into a single
contiguous range, and then execute a single delete command. I am not sure if
your data can tolerate sorting to achieve this. If you want to use the
filter, there is a way to select just the result of a filter using "Special
Cells" which was posted recently, but I am not sure where it is right now. I
have not done that part before personally.

Alex


"adidas VBA" wrote in message
...
There is a marginal improvement but the problem lies with a segment or
part of the macro code as presented below:
------------------
Dim r As Long
Application.ScreenUpdating = False
shtname = ActiveSheet.Name
With Worksheets(shtname)
For r = .UsedRange.Rows.Count To 1 Step -1
If .Cells(r, "K").Value = "0" Then
.Rows(r).Delete
End If
Next
End With
------------------

Can the code above be optimally meshed" or merged into the macro for
maximum efficiency, remains the question?

Presented below is the macro I presently use:

Sub test()
Dim r As Long
Application.ScreenUpdating = False
shtname = ActiveSheet.Name
With Worksheets(shtname)
For r = .UsedRange.Rows.Count To 1 Step -1
If .Cells(r, "K").Value = "0" Then
.Rows(r).Delete
End If
Next
End With
Dim mycounter As Double
Dim c As Range
Dim d As Range
mycounter = 1

Do While mycounter < 35001
Set c = Range("J" & mycounter)
Select Case c.Text
Case Is = "CRJ", "EM2", "ER3", "ER4", "ERD", "ERJ"
Set d = Range("E" & mycounter)
d.Value = d.Value & IIf(Right(d.Text, 1) < "E", "E", "")
End Select
mycounter = mycounter + 1
Loop
Application.ScreenUpdating = True
End Sub


Please respond. Appreciate everyone's help.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!