Passing array elements to a function

G

Geoff

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
 
G

Gary''s Student

You need to pass it back thru the name:

Public Function GetNum(num As Variant) As String
GetNum = "01234567"
End Function
 
G

Geoff

Hi
That was fine.

Thank you.

Geoff

Gary''s Student said:
You need to pass it back thru the name:

Public Function GetNum(num As Variant) As String
GetNum = "01234567"
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top