日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Excel中VBA相关函数的使用

發布時間:2023/12/9 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Excel中VBA相关函数的使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

自定義函數實例-單元顏色求和(字典+自定義函數)

Function COLORSUM(單元格區域 As range, 匯總的顏色 As range) Set d = CreateObject("Scripting.Dictionary") For Each Rng In 匯總的顏色d(Rng.Interior.ColorIndex) = "" Next For Each ci In d.keysFor Each Rng In 單元格區域If Rng.Interior.ColorIndex = ci Thenr = r + Rng.ValueEnd IfNextNext COLORSUM = r End Function Sub test() Set d = CreateObject("Scripting.Dictionary") Set 區域 = Application.InputBox("區域選擇", , , , , , , 8) Set 顏色 = Application.InputBox("顏色選擇", , , , , , , 8) For Each Rng In 顏色d(Rng.Interior.ColorIndex) = "" Next For Each ci In d.keysFor Each Rng In 區域If Rng.Interior.ColorIndex = ci Thenr = r + Rng.ValueEnd IfNextNext MsgBox rEnd Sub

自定義函數實例-反轉字符與數字求和(正則+自定義函數)

Function 求和(rng As Range, Optional s As String = "") Application.VolatileSet regx = CreateObject("vbscript.regexp") With regx.Global = True.Pattern = "\d" & sSet mat = .Execute(rng) End With For Each m In mat n = n + m * 1 Next 求和 = n End Function Function DD(rng As Range) '反轉字符 For i = Len(rng) To 1 Step -1a = Mid(rng, i, 1)b = b & a NextDD = b End Function

自定義函數實例-提取不重復值(字典+正則+自定義函數)

Function 不重復2(rng As Range, Optional num As Integer = 0) Set d = CreateObject("scripting.dictionary") Set regx = CreateObject("vbscript.regexp") With regx.Global = TrueIf num = 0 Then.Pattern = ".+" '所有值的不重復ElseIf num = 1 Then.Pattern = "[一-龢]+" '漢字不重復ElseIf num = 2 Then.Pattern = "[a-zA-Z]+" '字母不重復ElseIf num = 3 Then.Pattern = "\d+" '數字不重復End If For Each rn In rngFor Each m In .Execute(rn)d(m.Value) = ""Next Next 不重復2 = d.keys End With End Function Function 不重復值(rng As Range) Set d = CreateObject("scripting.dictionary") For Each rn In rngd(rn.Value) = "" Next 不重復值 = d.keys End Function

總結

以上是生活随笔為你收集整理的Excel中VBA相关函数的使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。