Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing array elements to a function
Hi
Passing the contents of the array element to the function works, the function does its job but returns "" to the array. It has to be something simple that I'm missing but it escapes me for now. Any help would be appreciated. Geoff Dim j As Long, realLastRow as Long Dim tbl2 As Variant tbl2 = Range(Cells(2, "A"), Cells(realLastRow, "A")) For j = LBound(tbl2, 1) To UBound(tbl2, 1) tbl2(j, 1) = GetNum(tbl2(j, 1)) Next j Range(Cells(2, "A"), Cells(realLastRow, "A")) = tbl2 Public Function GetNum(num As Variant) As String '''do something num = "01234567" End Function |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing array elements to a function
You need to pass it back thru the name:
Public Function GetNum(num As Variant) As String GetNum = "01234567" End Function -- Gary''s Student - gsnu200788 "Geoff" wrote: Hi Passing the contents of the array element to the function works, the function does its job but returns "" to the array. It has to be something simple that I'm missing but it escapes me for now. Any help would be appreciated. Geoff Dim j As Long, realLastRow as Long Dim tbl2 As Variant tbl2 = Range(Cells(2, "A"), Cells(realLastRow, "A")) For j = LBound(tbl2, 1) To UBound(tbl2, 1) tbl2(j, 1) = GetNum(tbl2(j, 1)) Next j Range(Cells(2, "A"), Cells(realLastRow, "A")) = tbl2 Public Function GetNum(num As Variant) As String '''do something num = "01234567" End Function |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Passing array elements to a function
Hi
That was fine. Thank you. Geoff "Gary''s Student" wrote: You need to pass it back thru the name: Public Function GetNum(num As Variant) As String GetNum = "01234567" End Function -- Gary''s Student - gsnu200788 "Geoff" wrote: Hi Passing the contents of the array element to the function works, the function does its job but returns "" to the array. It has to be something simple that I'm missing but it escapes me for now. Any help would be appreciated. Geoff Dim j As Long, realLastRow as Long Dim tbl2 As Variant tbl2 = Range(Cells(2, "A"), Cells(realLastRow, "A")) For j = LBound(tbl2, 1) To UBound(tbl2, 1) tbl2(j, 1) = GetNum(tbl2(j, 1)) Next j Range(Cells(2, "A"), Cells(realLastRow, "A")) = tbl2 Public Function GetNum(num As Variant) As String '''do something num = "01234567" End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Accessing individual elements of an array returned by a function | Excel Programming | |||
Passing indexed array value to VBA function | Excel Programming | |||
Transpose Function not Working with Long Array Elements | Excel Programming | |||
Passing array of strings from DLL function to VBA | Excel Programming | |||
Passing array to a function | Excel Programming |