當前位置:編程學習大全網 - 編程軟體 - EXCEL提取內容時過濾指定部分?

EXCEL提取內容時過濾指定部分?

EXCEL自身的函數沒有能實現這樣功能的,只有用VBA編程定義壹個函數來實現,效果如下圖:

上面的公式為:

=RegReplace(A1,"<\{.*?\}>[\s\n\r]*","")

其中的RegReplace是自定義函數,需要按ALT+F11添加模塊實現,代碼是這個樣子:

代碼的文本為:

Option Explicit

Function RegReplace(ByVal str1$, ByVal find$, ByVal rep$) As String

Dim re

Set re = CreateObject("VBScript.RegExp")

re.Pattern = find

re.Global = True

re.IgnoreCase = True

re.MultiLine = True

RegReplace = re.Replace(str1, rep)

End Function

  • 上一篇:怎麽用vba把exl中數據按關鍵字分解成不同的表格文件,並用關鍵字命名
  • 下一篇:未來世界是什麽樣子的?
  • copyright 2024編程學習大全網