View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JulieD JulieD is offline
external usenet poster
 
Posts: 4
Default Macro w/filter, copy, paste,& sort isn't working consistently

hi

one idea change
Header:=xlGuess
in your code to
Header:=xlNo

Cheers
JulieD



"kildevil " wrote in message
...
newbie here. I recorded this macro and cannot get the last bug out. I
have stepped thru it & do not see the problem.

I have a list of employees assigned to 3 shifts. My workbook's first
sheet (WORKING SHEET) lists:
*shift, seniority,names(alpha), hours previously worked, hours worked
this week, total hours. * Range= (A6:F72)
The macro is meant to (1) create a recovery sheet (OT BACKUP), (2)
Filter the names by shift, (3) copy & paste (special) the filtered
lists to another sheet (TOTAL OT SIGNUP), (4) finally sort each shift's
list in descending order by the "total hours" (primary) & descending
order "seniority" (secondary).

All functions but the sorting work properly. Frequently, the sorted
ranges work fine except for the first row. That row sits unsorted. I
have named the ranges for sorting. I have also designated the ranges,
rather than naming to see if it effect the outcome. It does not. I
have verified that when when I selected the Data, Sort, Range that the
bullet for "No Header" is selected.

One last bit of info: If I rerun the macro without any hours appearing
in the "hours worked this week" column, the sort works fine.

I apologize for my wordiness. Below in the MACRO. Please let me thank
anyone, in advance for any help.


OT_SHEET_2 Macro
' Macro recorded 2/9/2004 by ddd
'

'
Selection.AutoFilter Field:=1, Criteria1:="2"
ActiveSheet.ShowAllData
Sheets("TOTAL OT SIGN UP").Select
ActiveSheet.Unprotect
Application.Goto Reference:="DAY_SORT_RANGE"
Selection.ClearContents
Application.Goto Reference:="EVE_SORT_RANGE"
Selection.ClearContents
Application.Goto Reference:="MID_SORT_RANGE"
Selection.ClearContents
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("OT BACKUP").Select
ActiveSheet.Unprotect
Range("A6:E72").Select
Selection.ClearContents
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("WORKING SHEET").Select
Range("A6:E72").Select
Selection.Copy
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("OT BACKUP").Select
Range("A6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("WORKING SHEET").Select
Selection.AutoFilter Field:=1, Criteria1:="2"
Range("B6:F72").Select
Selection.Copy
Sheets("TOTAL OT SIGN UP").Select
Range("F3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Sheets("WORKING SHEET").Select
Selection.AutoFilter Field:=1, Criteria1:="1"
ActiveWindow.ScrollRow = 6
Application.CutCopyMode = False
Selection.Copy
Sheets("TOTAL OT SIGN UP").Select
Range("A3").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Sheets("WORKING SHEET").Select
Selection.AutoFilter Field:=1, Criteria1:="3"
Application.CutCopyMode = False
Selection.Copy
Sheets("TOTAL OT SIGN UP").Select
Range("F25").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("A3:E42").Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("E3"), Order1:=xlDescending,
Key2:=Range("A3") _
, Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase:= _
False, Orientation:=xlTopToBottom
Range("F3:J23").Select
Selection.Sort Key1:=Range("J3"), Order1:=xlDescending,
Key2:=Range("F3") _
, Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase:= _
False, Orientation:=xlTopToBottom
Range("F25:J42").Select
Selection.Sort Key1:=Range("J25"), Order1:=xlDescending,
Key2:=Range( _
"F25"), Order2:=xlDescending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom
ActiveWindow.ScrollRow = 1
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Sheets("WORKING SHEET").Select
ActiveSheet.ShowAllData
Range("F6:F72").Select
Selection.Copy
Range("D6").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("E6:E72").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("E6").Select
End Sub


---
Message posted from http://www.ExcelForum.com/