View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary''s Student Gary''s Student is offline
external usenet poster
 
Posts: 11,058
Default 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