i**a 发帖数: 11 | 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 | c**t 发帖数: 2744 | 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
| i**a 发帖数: 11 | 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
| c**t 发帖数: 2744 | 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
|
|