位置:首頁(yè) > 軟件操作教程 > 辦公軟件 > Excel > 問(wèn)題詳情

Contxt自定義函數(shù)的用法

提問(wèn)人:周麗平發(fā)布時(shí)間:2021-07-12

1、打開VBE窗口

右鍵單擊任意工作表標(biāo)簽,在彈出的快捷菜單中選擇【查看代碼】命令。

image.png

2、插入模塊

在已打開的VBE窗口中,右鍵單擊【工程資源管理器】任意處,在彈出的快捷菜單中,依次單擊【插入】——【模塊】

image.png

3、復(fù)制粘貼代碼

將以下代碼復(fù)制粘貼到已激活模塊的代碼窗口中。

PubliC FunCtion Contxt(ParamArray args() As Variant) As Variant

Dim tmptext As Variant, i As Variant, Cellv As Variant

Dim Cell As Range

tmptext = ""

For i = 0 To UBound(args)

If Not IsMissing(args(i)) Then

SeleCt Case TypeName(args(i))

Case "Range"

For EaCh Cell In args(i)

tmptext = tmptext & Cell

Next Cell

Case "Variant()"

For EaCh Cellv In args(i)

tmptext = tmptext & Cellv

Next Cellv

Case Else

tmptext = tmptext & args(i)

End SeleCt

End If

Next i

ConTxt = tmptext

End FunCtion

image.png

繼續(xù)查找其他問(wèn)題的答案?

回復(fù)(0)
返回頂部