Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1489|回复: 3

[已解决]求助一个代码

[复制链接]
发表于 2010-1-25 15:54 | 显示全部楼层 |阅读模式

向各位老师求助一个代码,谢谢了先!!!!,

wf3xBelR.rar (2.3 KB, 下载次数: 0)
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2010-1-25 16:00 | 显示全部楼层
回复

使用道具 举报

发表于 2010-1-25 17:08 | 显示全部楼层

Sub 排序()
  Dim Arr, Ay, By, cR_n&, i&, j%, x%, y%, k%, S$, N%
  Dim Dic As New Dictionary
    cR_n = [c65536].End(xlUp).Row
    Arr = Range("C3:G" & cR_n)
    For i = 1 To UBound(Arr)
      S = ""
      Ay = Application.Index(Arr, i)
      For j = 1 To UBound(Ay)
        If InStr(S, Ay(j)) = 0 Then
          S = S & "+" & Ay(j)
        End If
      Next
      By = Split(Right(S, Len(S) - 1), "+")
      k = UBound(By) - 1
      For x = 0 To k
        For y = 0 To k - x
          If By(y) > By(y + 1) Then
            N = By(y)
            By(y) = By(y + 1)
            By(y + 1) = N
          End If
        Next
      Next
      Dic(Join(By, "")) = i
    Next
    Range("P:P").ClearContents
    [P3].Resize(Dic.Count, 1) = Application.Transpose(Dic.Keys)
    Range("P3:P" & [p65536].End(xlUp).Row).Sort Key1:=Range("P3"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _
        :=xlPinYin, DataOption1:=xlSortNormal
End Sub
回复

使用道具 举报

发表于 2010-1-25 17:12 | 显示全部楼层    本楼为最佳答案   

1DWogqdz.rar (9.17 KB, 下载次数: 10)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-30 07:27 , Processed in 0.219689 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表