Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array used in a procedure 2

Status
Not open for further replies.

Numbers1

Technical User
Dec 27, 2003
34
US
I want a procedure that loads a calling array with the data contained in predefined row and column references of the active spreadsheet. I have gotten this far with the code shown below.
When run, the procedure loads the data but does not pass it back to the calling array. What is missing within the subLoadArray?

Dim aryFunds (6, 3) as Variant

Public Sub UserForm_Initialize()

Range ("A1").select

subLoadArray(aryFunds)

End Sub


Private Sub subLoadArray(ByVal ArrayName As Variant) ' load calling array with data

Dim intRow As Integer
Dim intCol As Integer

For intRow = 1 To UBound(ArrayName)
For intCol = 1 To UBound(ArrayName, 2)
strCellContents = ActiveSheet.Cells(intRow, intCol)
ArrayName(intRow, intCol) = strCellContents
Next intCol
Next intRow


End Sub

NOTE: ByRef in the procedure doesn't help either.

Thanks, Numbers
 
Change ByVal to ByRef.
ByRef ArrayName As Variant.
If you had passed an array rather than a Variant that contains an array, you would have gotten a compiler error for ByVal.

Given that the data appears to be String, why not do

Dim aryFunds (6, 3) as String
Public Sub UserForm_Initialize()

Range ("A1").select

subLoadArray(aryFunds)

End Sub


Private Sub subLoadArray(ByRef ArrayName() As String) ' load calling array with data



Forms/Controls Resizing/Tabbing
Compare Code
Generate Sort Class in VB
Check To MS)
 
You either need to add CALL or remove the brackets

Call subLoadArray(aryFunds)

or

subLoadArray aryFunds


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top