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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with arrays

Status
Not open for further replies.

redlam

MIS
Jun 28, 2000
218
US
i'm such a newbie its embarrassing...
can anyone help me with the following issue?
i have an excel spreadsheet that i need to populate from a sql stored procedure. i am using the following code to connect to sql and access the stored procedure:

Private Sub CommandButton1_Click()
Dim databaseName As String
Dim queryString As String
Dim returnArray

databaseName = "TimeTrak_SQL"
queryString = "exec usp_get_user_timeschedule"

returnArray = SQLRequest("dsn=" & databaseName, queryString)


End Sub

i'm completely unfamiliar with arrays and i need to be able to figure out how many elements the array contains and the size of each element so that i can set the cell values on the excel spreadsheet to the values in the array. the spreadsheet is in a fixed format and normally requires manaul data entry. thank you to anyone who responds!
 
nevermind... i got it. this still places cells one by one unconditionally but i think its a start.

Private Sub CommandButton1_Click()
Dim databaseName As String
Dim queryString As String
Dim returnArray

databaseName = "TimeTrak_SQL"
queryString = "exec usp_get_user_timeschedule"

returnArray = SQLRequest("dsn=" & databaseName, queryString)

For i = LBound(returnArray, 1) To UBound(returnArray, 1)
For j = LBound(returnArray, 2) To UBound(returnArray, 2)
Worksheets("Timesheet").Cells(i, j).Formula = returnArray(i, j)
Next j
Next i

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top