yn19832
03-23-2007, 07:40 AM
I want to transfer the array "varArray" to the shee1 with the following codes, but it turned out to be a mass. The data in "tblIndex" is like this
Date Country Type Index
31/03/1980 Canada A 1
... ... ... ...
Set rec = db.OpenRecordset("tblIndex", dbOpenDynaset)
If Not rec.EOF Then
rec.MoveLast
rec.MoveFirst
intRecord = rec.RecordCount
varArray = rec.GetRows(intRecord)
intFieldCount = UBound(varArray, 1)
intRowCount = UBound(varArray, 2)
' Make Sure Sheet1 is Activate
Sheets("Sheet1").Activate
' Set worksheet range
Set TheRange = ActiveCell.Range(Cells(1, 1), Cells(intRowCount + 1, intFieldCount + 1))
' Copy the record to Excel
TheRange.Value = varArray
Date Country Type Index
31/03/1980 Canada A 1
... ... ... ...
Set rec = db.OpenRecordset("tblIndex", dbOpenDynaset)
If Not rec.EOF Then
rec.MoveLast
rec.MoveFirst
intRecord = rec.RecordCount
varArray = rec.GetRows(intRecord)
intFieldCount = UBound(varArray, 1)
intRowCount = UBound(varArray, 2)
' Make Sure Sheet1 is Activate
Sheets("Sheet1").Activate
' Set worksheet range
Set TheRange = ActiveCell.Range(Cells(1, 1), Cells(intRowCount + 1, intFieldCount + 1))
' Copy the record to Excel
TheRange.Value = varArray