Excel精英培训网

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

较长字符串处理,用vba解决

[复制链接]
发表于 2019-10-11 17:58 | 显示全部楼层 |阅读模式
提取字符串中需要的内容到指定单元格中, 字符串处理.zip (5.94 KB, 下载次数: 13)
发表于 2019-10-11 20:22 | 显示全部楼层
  1. Sub yy()
  2.   Dim ReGe As Object, Arr As Variant
  3.   Dim a As Variant, b As Variant, c As Long
  4.    Set ReGe = CreateObject("VbsCript.RegeXp")
  5.      With ReGe
  6.         .Global = True
  7.         .Pattern = """CORPNAME"":""(.*?)"".*?""SCORE"":(\d*\.?\d+)"
  8.         Set a = .Execute([a1].Value)
  9.          ReDim Arr(1 To a.Count, 1 To 2)
  10.           For Each b In a
  11.              c = c + 1
  12.              Arr(c, 1) = b.submatches(0)
  13.              Arr(c, 2) = b.submatches(1)
  14.           Next b
  15.      End With
  16. Range("B16").Resize(c, 2) = Arr
  17. End Sub
复制代码
回复

使用道具 举报

 楼主| 发表于 2019-10-12 14:22 | 显示全部楼层
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-18 21:01 , Processed in 0.130958 second(s), 16 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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