avatar
a vba question. please help# Programming - 葵花宝典
i*a
1
I want to wrote a vba function, which returns the name of a user defined
variable. However, my code seems never work. Could someone please look into
my code and point me out? thank you so much.
Function test(s As String)
Dim a(5) As Integer
For idx = 1 To 5
a(idx) = idx
Next idx
ActiveWorkbook.Names.Add Name:=s, RefersTo:=a
test= s
End Function
avatar
c*t
2

into
Don't understand your code; to list all names:
Sub ListAllNames()
Row = 1
For Each n In ActiveWorkbook.Names
Cells(Row, 1) = n.Name
Cells(Row, 2) = " " & n.RefersTo
Row = Row + 1
Next n
End Sub

【在 i**a 的大作中提到】
: I want to wrote a vba function, which returns the name of a user defined
: variable. However, my code seems never work. Could someone please look into
: my code and point me out? thank you so much.
: Function test(s As String)
: Dim a(5) As Integer
: For idx = 1 To 5
: a(idx) = idx
: Next idx
: ActiveWorkbook.Names.Add Name:=s, RefersTo:=a
: test= s

avatar
i*a
3
The function compute a array "a". Instead of returning the array itself to
spreadsheet, I want to return a name, "s", for this array.

into

【在 i**a 的大作中提到】
: I want to wrote a vba function, which returns the name of a user defined
: variable. However, my code seems never work. Could someone please look into
: my code and point me out? thank you so much.
: Function test(s As String)
: Dim a(5) As Integer
: For idx = 1 To 5
: a(idx) = idx
: Next idx
: ActiveWorkbook.Names.Add Name:=s, RefersTo:=a
: test= s

avatar
c*t
4
can I rephrase your requirment as "define a function to compute a named rang
e"?
Name should be the collection of cells or objects. I don't think you can def
ine the computed array (scalar) with a name.

【在 i**a 的大作中提到】
: The function compute a array "a". Instead of returning the array itself to
: spreadsheet, I want to return a name, "s", for this array.
:
: into

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。