|
Sub 排列()
Sheet1.Activate
Sheet1.Range("A2:H" & Sheet1.[a60000].End(xlUp).Row).Select
With Sheet1.Sort
With .SortFields
.Clear
.Add Key:=Range("H2:H" & Sheet1.[a60000].End(xlUp).Row), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder:=""
End With
.Header = xlNo
.Orientation = xlSortColumns
.MatchCase = False
.SortMethod = xlPinYin
.SetRange Rng:=Selection
.Apply
End With '辅助列乱序
arr = Sheet1.Range("a1").CurrentRegion
Sheet3.Activate
With Sheet3
.Cells.Clear
lie = 1
zu = 1
hang = 2
For 项目列 = 5 To 7
If .Cells(.[b60000].End(xlUp).Row, "B") = "" Then
.Cells(.[b60000].End(xlUp).Row, "A") = arr(2, 4)
.Cells(.[b60000].End(xlUp).Row, "B") = arr(1, 项目列)
Else
.Cells(.[b60000].End(xlUp).Row + 2, "A") = arr(2, 4)
.Cells(.[b60000].End(xlUp).Row + 2, "B") = arr(1, 项目列)
hang = hang + 5
zu = 1
lie = 1
End If
For a = 2 To UBound(arr)
If arr(a, 项目列) <> "" Then
lie = lie + 1
If lie = 8 Then
lie = 2
hang = hang + 3
zu = zu + 1
End If
.Cells(hang, 1) = zu & "组"
.Cells(hang, lie) = lie - 1 & "道"
.Cells(hang + 1, lie) = arr(a, 3)
.Cells(hang + 2, lie) = arr(a, 项目列)
End If
Next
Next
End With
End Sub '仅供参考,自己修修改改吧,每一次需求和表都不一样,去淘宝找个代工吧。
|
评分
-
1
查看全部评分
-
|