0

I have created an array named "arrRecords" using a query from ODBC. I want to output the value of that array into my worksheet. The array has 4 columns but the number of rows depends on the query. How do i do this?

Please help.

3

1 Answer 1

0

Something like this should work:

Sub printarray(arrRecords)

Dim i As Long, j As Long

For i = 1 To 4
      For j = 1 To UBound(arrRecords, 2)
            ActiveSheet.Cells(j, i).Value = arrRecords(i, j)
      Next j
Next i

End Sub

Activesheet.cells needs to be replaced with whatever loaction you want to input the array.

Note that depending on your set up the dimensions may be switched. With ubound(array,2) one can get the Upperbound of an array second dimension. Then just loop through it. Note also that i and j do not have to start with 1 this is dependend on your case.

Flies away!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.