Excel精英培训网

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

[已解决]提取重复出现文字多到少排序

[复制链接]
发表于 2016-4-12 16:32 | 显示全部楼层 |阅读模式
如图
最佳答案
2016-4-13 09:25
............
QQ截图20160412162040.png

新建 Microsoft Excel 工作表.zip

2.32 KB, 下载次数: 16

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2016-4-12 16:48 | 显示全部楼层
  1. Sub tt()
  2.     Set d = CreateObject("scripting.dictionary")
  3.     arr = [a1].CurrentRegion
  4.     For i = 2 To UBound(arr)
  5.         x = arr(i, 1): L = Len(x)
  6.         For k = 1 To L
  7.             y = Mid(x, k, 1)
  8.             d(y) = d(y) + 1
  9.         Next
  10.         ReDim brr(L)
  11.         For Each y In d.keys
  12.             p = d(y)
  13.             brr(L - p) = brr(L - p) & y
  14.         Next
  15.         arr(i, 2) = Join(brr, "")
  16.     Next
  17.     [a1].CurrentRegion = arr
  18. End Sub
复制代码

新建 Microsoft Excel 工作表.rar

9.5 KB, 下载次数: 8

回复

使用道具 举报

发表于 2016-4-12 16:49 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2016-4-12 16:54 | 显示全部楼层
grf1973 发表于 2016-4-12 16:48

非常感谢!如果A列有很多文字呢,比如A1到A1000都有数据,如何在B列对应提取出来呢?
回复

使用道具 举报

发表于 2016-4-12 17:01 | 显示全部楼层
Sub test()
Dim a()
st1$ = [a2]
i% = Len(st1)
ReDim a(1 To i)
Do While Len(st1)
   st2$ = Left(st1, 1)
   a(i - Len(st1) + Len(Replace(st1, st2, ""))) = a(i - Len(st1) + Len(Replace(st1, st2, ""))) & st2
   st1 = Replace(st1, st2, "")
Loop
[a3] = Join(a, "")
End Sub
回复

使用道具 举报

发表于 2016-4-12 17:23 | 显示全部楼层
本帖最后由 pengyx 于 2016-4-12 17:38 编辑

Function pengyx(ss As String)'用法“=pengyx(a1)”
Set d = CreateObject("scripting.dictionary")
a = Len(ss)
ReDim ar(1 To a, 1 To 2)
For i = 1 To a
    t = Mid(ss, i, 1)
    r = d(t)
    If r = "" Then
        s = s + 1
        d(t) = s
        ar(s, 1) = t
        ar(s, 2) = 1
    Else
        ar(r, 2) = ar(r, 2) + 1
    End If
Next
    For j = 1 To s
        For k = j + 1 To s - 1
            If ar(k, 2) > ar(j, 2) Then
                x1 = ar(k, 1): x2 = ar(k, 2)
                ar(k, 1) = ar(j, 1): ar(k, 2) = ar(j, 2)
                ar(j, 1) = x1: ar(j, 2) = x2
            End If
        Next
    tt = tt & ar(j, 1)
    Next
pengyx = tt
End Function


回复

使用道具 举报

 楼主| 发表于 2016-4-12 17:51 | 显示全部楼层
pengyx 发表于 2016-4-12 17:23
Function pengyx(ss As String)'用法“=pengyx(a1)”
Set d = CreateObject("scripting.dictionary")
a = ...

你好,这个怎么用?可以给一个附件吗?
回复

使用道具 举报

 楼主| 发表于 2016-4-12 17:51 | 显示全部楼层
上清宫主 发表于 2016-4-12 17:01
Sub test()
Dim a()
st1$ = [a2]

你好,这个怎么用?可以给一个附件吗?
回复

使用道具 举报

发表于 2016-4-12 19:06 | 显示全部楼层
学习了!!
回复

使用道具 举报

发表于 2016-4-12 20:35 | 显示全部楼层
雨夜1987 发表于 2016-4-12 16:54
非常感谢!如果A列有很多文字呢,比如A1到A1000都有数据,如何在B列对应提取出来呢?

直接用即可
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-25 04:02 , Processed in 0.498674 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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