|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 Vicel 于 2014-11-24 18:11 编辑
gaoch35 发表于 2014-11-24 16:06
只排F列就可以了,其他的不变
看效果如何?是否符合楼主要求- Sub PX()
- Cs = ActiveSheet.UsedRange.Columns.Count
- Rs = ActiveSheet.UsedRange.Rows.Count
- Brr = Columns("E"): Columns("E").ClearContents
- Crr = Columns("G"): Columns("G").ClearContents
- i = 1
- Do
- If Cells(i, 6) <> "" Then
- n = i
- Else
- n = Range("F" & i).End(xlDown).Row
- End If
- s = Range("F" & n).CurrentRegion.Rows.Count
- arr = Range("F" & n & ":F" & n + s)
- Range(Chr(Cs + 65) & n).Resize(UBound(arr), 1) = s
- i = n + s
- Loop Until i > Range("F65536").End(xlUp).Row
- Range("E1").Resize(UBound(Brr), 1) = Brr
- Range("G1").Resize(UBound(Crr), 1) = Crr
- Range(Cells(1, 1), Cells(Rs, Cs + 1)).Sort Key1:=Range(Chr(Cs + 65) & "1"), Order1:=xlAscending, Header:=xlGuess, _
- OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
- :=xlPinYin, DataOption1:=xlSortNormal
- Columns(Chr(Cs + 65)).ClearContents
- End Sub
复制代码
|
|