View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Worksheet sorting code/technique advise

Hi Howard,

Am Tue, 6 Aug 2013 04:09:05 -0700 (PDT) schrieb Howard:

For i = LBound(MyCol) To UBound(MyCol)
Sh.Sort.SortFields.Add Key:=Cells(1, MyCol(i)) And Headers = xlNo _

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^
Sh.Sort.SortFields.Add Key:=Cells(1, MyCol(i)) _
, SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
Next
With Sh.Sort
.SetRange Sh.UsedRange
.Header = xlNo
'.Header = xlYes

^^^^^^^^^^^^^
Header=xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With


sorry that I confused you :-(
Headers is under Sh.Sort

Try:
Sh.Sort.SortFields.Clear
For i = LBound(MyCol) To UBound(MyCol)
Sh.Sort.SortFields.Add Key:=Cells(1, MyCol(i)) _
, SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
Next
With Sh.Sort
.SetRange Sh.UsedRange
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2