View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Trevor Shuttleworth Trevor Shuttleworth is offline
external usenet poster
 
Posts: 1,089
Default Adjusting VBA code for some flexibility

My code combined with that from JE should be quicker:

Sub Macro1()
Dim VisibleRange As Range
Dim rCell As Range
With Range("A1")
.AutoFilter
.AutoFilter Field:=5, Criteria1:="CO"
Set VisibleRange = _
Intersect(.SpecialCells(xlCellTypeVisible), _
Columns("E"), _
ActiveSheet.UsedRange)
End With
For Each rCell In VisibleRange
With rCell
If .Value = "CO" Then
Select Case .Offset(0, 5).Text
Case "CRJ", "EM2", "ER3", "ER4", "ERD", "ERJ"
.Value = .Value & _
IIf(Right(.Text, 1) < "E", "E", "")
End Select
End If
End With
Next rCell
End Sub

You could do a similar thing to filter the 0 cells and delete the rows.
Should also be quicker than looping 35000 times.

Regards

Trevor


"adidas VBA" wrote in message
...
Column E has several airline codes (CO, NW, AA, etc.) and I want only CO
to be impacted by my macro. The macro presently applies to all airlines
that operate EMB, CRJ, etc. type aircraft. I want to further narrow the
scope of the macro to only CO which is continental airlines. The macro
will add an E to all CO flights that operate regional jet aircraft such
as EMB, CRJ, others as mentioned in the macro. How can I adjust my
original macro to impact only CO and none of the other airlines?

Thanks.

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