Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 371
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing individual elements of an array returned by a function [email protected] Excel Programming 1 March 19th 08 06:13 AM
Passing indexed array value to VBA function [email protected] Excel Programming 7 August 9th 06 12:57 AM
Transpose Function not Working with Long Array Elements Ngan Excel Programming 1 August 9th 05 08:59 PM
Passing array of strings from DLL function to VBA Jag Man Excel Programming 0 January 12th 04 10:09 PM
Passing array to a function GB[_3_] Excel Programming 3 October 21st 03 09:59 AM


All times are GMT +1. The time now is 07:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"