Excel VBA函式不能傳入多個引數嗎

2021-04-18 23:09:07 字數 1029 閱讀 2529

1樓:匿名使用者

'可以傳bai

入多個引數du

'使用 paramarray 關鍵zhi字可以使函dao數接收數目可變的引數

function calcsum(byval firstarg as integer, paramarray otherargs())

dim i as integer

calcsum = firstarg

for i = 0 to ubound(otherargs)calcsum = calcsum + otherargs(i)next

end function

'如果用如下**呼叫該函專數:

sub example1()

dim returnvalue

'區域性變數賦予

屬以下值:firstarg = 4,

'otherargs(0) = 3,otherargs(1) = 2,otherargs(2) = 1,等等。

returnvalue = calcsum(4, 3, 2, 1)msgbox returnvalue

end sub

excel vba函式中可選引數問題

2樓:匿名使用者

因為你的「自定義函式 裡邊的引數 你已經都給定下來了 所以不能有別的引數了值了……

自定義函式 的寫法不是你這樣子的吧?裡邊只給引數名稱 不要給定值!!!!!!

通過excel vba自定義了一個函式,無法把陣列傳入到函式中。

3樓:匿名使用者

只能傳單元格,然後轉陣列。如下

function mytest(rng as range)dim arr() as variant

set arr = rng.value

mytest = ubound(arr)

end function

4樓:匿名使用者

這要用paramarray的。

和尚到底能不能吃肉佛教傳入中國2019多年竟然沒人知道

漢傳佛教不可以吃肉,但是在 阿含經 與四律五論中,並無禁止食肉的戒律,相反,多處提及居士以魚肉供養比丘。如 十誦律 卷13提到佛陀對諸比丘說 從今聽食五種蒲闍尼食,謂飯 麨 糒 魚 肉,五種食自恣受 摩訶僧祇律 卷16中記載有居士通夜煮肉,做麥飯肉段供養比丘。阿含經 與 四分律 還特別提到一些外道以...

excel vba多列資料求和,要求用VBA字典

sub 多列相同項累計 dim dic,istr as string set dic createobject scripting.dictionary with activesheet for i 1 to range a65536 end xlup row istr cells i,1 cell...

excel VBA自定義函式如何進行陣列計算

function f myrange as range dim myarr 1 to 5 dim myr as range dim i as single i 1 for each myr in myrangemyarr i myr.value i i 1 next f myarr 1 myarr ...