Anne Troy
MrExcel MVP
- Joined
- Feb 18, 2002
- Messages
- 2,632
- Office Version
- 365
- Platform
- Windows
No clue why this works on my machine, but throws a 438 on another user's machine. Anybody? This is all my code. It's my boss, so I didn't exactly want to get him involved in debugging. Let me know if I MUST. I figure it's something I can't pick out because I steal code, I don't really write much.
Code:
Sub LNSort()
'
LastRow = Range("A" & Rows.Count).End(xlUp).Row
'
Columns("A:AH").Select
ActiveWorkbook.Worksheets("ALL").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("ALL").Sort.SortFields.Add2 Key:=Range("E2:E" & LastRow), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("ALL").Sort.SortFields.Add2 Key:=Range("F2:F" & LastRow), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("ALL").Sort
.SetRange Range("A1:AH" & LastRow)
.Header = xlYes
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("A2").Select
End Sub
Sub GetATL()
'Get Atlas Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=2, Criteria1:="ATL"
Range("A2").Select
End Sub
Sub GetMST()
'Get Med-Spec Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=2, Criteria1:="MST"
Range("A2").Select
End Sub
Sub GetLTM()
'Get Logistics Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=2, Criteria1:="LTM"
Range("A2").Select
End Sub
Sub GetALL()
'Clear filters
If ActiveSheet.AutoFilterMode Then ActiveSheet.AutoFilterMode = False
Range("A2").Select
'
' ActiveSheet.ShowAllData
' Range("A2").Select
End Sub
Sub GetECTM()
'Get All Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=1, Criteria1:="ECT"
Range("A2").Select
End Sub
Sub GetPXTM()
'Get Med-Spec Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
LastRowE = Range("E" & Rows.Count).End(xlUp).Row
LastRowA = Range("A" & Rows.Count).End(xlUp).Row
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=1, Criteria1:="PXT"
Range("A2").Select
End Sub
Sub GetMWTM()
'Get Logistics Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=1, Criteria1:="MWT"
Range("A2").Select
End Sub
Sub GetWCTM()
'Get Logistics Drivers Only
If ActiveSheet.AutoFilterMode Then ActiveSheet.Cells.AutoFilter
If ActiveSheet.AutoFilterMode Then ActiveSheet.ShowAllData
Call LNSort
Selection.AutoFilter
ActiveSheet.Range("$A:$A").AutoFilter Field:=1, Criteria1:="WCT"
Range("A2").Select
End Sub