Excel精英培训网

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

[已解决]模糊去重,数据提取。请大神帮忙,不胜感激!!

[复制链接]
发表于 2022-2-26 18:56 | 显示全部楼层 |阅读模式
3学分
本帖最后由 别离殇情 于 2022-2-26 18:59 编辑

样本数据.rar (431 KB, 下载次数: 5)

最佳答案

查看完整内容

要求都满足 Sub test() On Error Resume Next Dim i%, Match, Dic As Object Set Dic = CreateObject("scripting.dictionary") For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row Dic(Left(Cells(i, 1), 55)) = "" Next i Range(Cells(2, 1), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 1)).ClearContents [A2].Resize(UBound(Dic.keys) + 1, 1) = Application.Transpose(Dic.keys) ...
发表于 2022-2-26 18:56 | 显示全部楼层    本楼为最佳答案   
本帖最后由 limonet 于 2022-2-26 22:09 编辑

要求都满足
Sub test()
    On Error Resume Next
    Dim i%, Match, Dic As Object
    Set Dic = CreateObject("scripting.dictionary")
    For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
        Dic(Left(Cells(i, 1), 55)) = ""
    Next i
    Range(Cells(2, 1), Cells(Cells(Rows.Count, 1).End(xlUp).Row, 1)).ClearContents
    [A2].Resize(UBound(Dic.keys) + 1, 1) = Application.Transpose(Dic.keys)
    For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
        With CreateObject("vbscript.regexp")
            .Global = True
            .MultiLine = True
            .Pattern = "[0-9]{8,11}"
            Cells(i, 1) = .Replace(Cells(i, 1), "12345678900")
            .Pattern = "(?=售)?[0-9]{2,}\.?[0-9]{0,2}?万"
            Set Match = .Execute(Cells(i, 1))
            Cells(i, 2) = Match(0)
            .Pattern = "[0-9]{2,}\.?[0-9]{0,2}?平?[平方]"
            Set Match = .Execute(Cells(i, 1))
            Cells(i, 3) = Match(0)
        End With
    Next i
End Sub

样本数据.zip

511 KB, 下载次数: 8

回复

使用道具 举报

 楼主| 发表于 2022-2-26 22:05 | 显示全部楼层
limonet 发表于 2022-2-26 21:52
要求都满足
Sub test()
    On Error Resume Next

感谢大神帮忙,数据提取做的非常准确
还有一个问题,他这个模糊去重问题能不能解决  
附件中已标出需要去重的例子 样本数据2.rar (378.89 KB, 下载次数: 3)
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-17 06:51 , Processed in 0.256331 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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