Attribute VB_Name = "xSrt" |
|
Const cMod$ = cLib & ".xSrt" |
|
Function Srt_Ay(pAy$(), oAy$()) As Boolean |
|
Const cNmtTmp$ = "TmpSrt" |
|
If jj.Siz_Ay(pAy) = 0 Then oAy = pAy: Exit Function |
|
If jj.Dlt_Tbl(cNmtTmp) Then ss.A 1: GoTo E |
|
If jj.Run_Sql(jj.Fmt_Str("Create table {0} (aa Text(255))", cNmtTmp)) Then ss.A 2: GoTo E |
|
With CurrentDb.OpenRecordset("Select * from " & cNmtTmp) |
|
Dim J%: For J = LBound(pAy) To UBound(pAy) |
|
ReDim oAy(LBound(pAy) To UBound(pAy)) |
|
With CurrentDb.OpenRecordset("Select * from " & cNmtTmp & " order by aa") |
|
If jj.Dlt_Tbl(cNmtTmp) Then ss.A 3: GoTo E |
|
E: Srt_Ay = True: ss.B cSub, cMod |
|
Function Srt_Ay_Tst() As Boolean |
|
If jj.Srt_Ay(mA, mB) Then Stop |
|
Debug.Print jj.Siz_Ay(mB) |
|
Function Srt_Coll(oColl As VBA.Collection, pColl As VBA.Collection) As Boolean |
|
Const cSub$ = "Srt_SortColl" |
|
If jj.Dlt_Tbl(cNmtTmp) Then ss.A 1: GoTo E |
|
If jj.Run_Sql(jj.Fmt_Str("Create table {0} (aa Text(255))", cNmtTmp)) Then ss.A 1: GoTo E |
|
Dim iStr: For Each iStr In pColl |
|
If jj.Run_Sql("insert into [" & cNmtTmp & "] (aa) values('" & iStr & "')") Then ss.A 2: GoTo E |
|
Set oColl = New VBA.Collection |
|
With CurrentDb.OpenRecordset("Select * from [" & cNmtTmp & "] order by aa") |
|
oColl.Add CStr(!aa.Value) |
|
Sheet1.Cells(iRno, 1).Value = iStr |
|
Sheet1.Range("A1:A" & iRno).Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlNo, _ |
|
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ |
|
DataOption1:=xlSortNormal |
|
Set oColl = New VBA.Collection |
|
oColl.Add Sheet1.Cells(iRno, 1).Value |
|
E: Srt_Coll = True: ss.B cSub, cMod, "pColl", jj.ToStr_Coll(pColl) |
|
If pLv$ = "" Then Srt_Lv = "": Exit Function |
|
Dim mAy1$(): mAy1 = Split(pLv, cComma) |
|
Dim mAy2$(): If jj.Srt_Ay(mAy1, mAy2) Then ss.A 1, "Cannot sort array": GoTo E |
|
Srt_Lv = Join(mAy2, cComma) |
|
E: ss.B cSub, cMod, "pLv", pLv |
|
Function Srt_Pt(pPt As PivotTable) As Boolean |
|
For Each iPf In pPt.PivotFields |
|
If .Name <> "Data" Then .AutoSort xlAscending, .Name |
|
End Function
|