asked on
With xlswb.Worksheets("Received").Sort
.SortFields.Add Key:=xlsws.Range("N2:N2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.SortFields.Add Key:=xlsws.Range("O2:O2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
With xlswb.Worksheets("Received").Sort
.SortFields.Add Key:=xlsws.Range("N2:N2000"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
.SortFields.Add Key:=xlsws.Range("O2:O2000"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
.Apply
End With
ASKER
With xlsws.Cells
.Sort Key:=xlsws.Range("N2:N2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Sort Key:=xlsws.Range("O2:O2000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
With xlsws.Cells
.Sort Key1:=xlsws.Range("N2:N2000"), SortOn1:=xlSortOnValues, Order1:=xlAscending, DataOption1:=xlSortNormal
.Sort Key1:=xlsws.Range("O2:O2000"), SortOn1:=xlSortOnValues, Order1:=xlAscending, DataOption1:=xlSortNormal
End With
ASKER
ASKER
Sub test()
Dim xlsApp As Excel.Application
Dim xlsWbk As Excel.Workbook
Dim xlsSht As Excel.Worksheet
Set xlsApp = Excel.Application
Set xlsWbk = xlsApp.Workbooks.Open("C:\test.xls")
Set xlsSht = xlsWbk.ActiveSheet
xlsApp.Visible = True
With xlsSht.Cells
.Sort Key1:=.Range("N1"), Order1:=xlAscending, Key2:=.Range("O1") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
End With
End Sub
ASKER
ASKER
Set xlsws = xlswb.Worksheets("Received")
xlsapp.Visible = True
With xlsws.Cells
.Sort Key1:=.Range("A1"), Order1:=xlAscending _
, Key2:=.Range("B1"), Order2:=xlAscending _
, Key3:=.Range("C1"), Order3:=xlAscending _
, Key4:=.Range("D1"), Order4:=xlAscending _
, Key5:=.Range("E1"), Order5:=xlAscending _
, Key6:=.Range("F1"), Order6:=xlAscending _
, Key7:=.Range("G1"), Order7:=xlAscending _
, Key8:=.Range("H1"), Order8:=xlAscending _
, Key9:=.Range("I1"), Order9:=xlAscending _
, Key10:=.Range("J1"), Order10:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom _
, DataOption1:=xlSortNormal _
, DataOption2:=xlSortNormal _
, DataOption3:=xlSortNormal _
, DataOption4:=xlSortNormal _
, DataOption5:=xlSortNormal _
, DataOption6:=xlSortNormal _
, DataOption7:=xlSortNormal _
, DataOption8:=xlSortNormal _
, DataOption9:=xlSortNormal _
, DataOption10:=xlSortNormal
End With
ASKER
ASKER
ASKER
With ActiveSheet.Sort
With .SortFields
.Clear
.Add Key:=Range("A2:A16"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("B2:B16"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("C2:C16"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
.Add Key:=Range("D2:D16"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
End With
.SetRange Range("A:O")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.
TRUSTED BY
Open in new window