View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] luongmq@gmail.com is offline
external usenet poster
 
Posts: 1
Default Range Parameters in Function

Greetings All,

I am trying to understand why this function does not work. Any
suggestions would greatly be appreciated it.

Public Function GetArray(ByVal rng1 As Range, ByVal rng2 As Range) As
String
' rng1 is a 1-cell range; rng2 1-cell range
Dim vReturn As Variant
Dim oSecret As Object
Dim i As Integer

On Error GoTo ErrorHandler
Set oSecret = CreateObject("SomeDLL.Class")
vReturn = oSecret.GetSecretArray(rng1.Cells.Value)

GetArray = vbNullString
For i = 0 to UBound(vReturn) Step 1
GetArray = GetArray & vReturn(i) ' this is line is fine
rng2.Cells(i + 1).Value = vReturn(i) ' this line kicks the function
out; rng2.Offset(i) does not work either, rng2.<whatever.FormulaR1C1
does not help either
Next i
Exit Function
:ErrorHandler
MsgBox Err.Description
End Function