Below VBA code does the job, but I'm losing some 3 sec in the transpose part.
Is there a way I can get the same result or in the SQL query or in the getrows process without losing the 3 secs?
Sub LoadData()
Dim strCon, srtQry As String, tmpArray, tmpArray2, R As Variant, i, j As Long
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
strCon = "DRIVER={MySQL ODBC 5.2 ANSI Driver};" & _
"SERVER=localhost;" & _
"DATABASE=tbname;" & _
"USER=root;" & _
"PASSWORD=pass;" & _
"Port=3306;" & _
"Option=3"
cn.Open strCon
srtQry = "SELECT * FROM `tbname` WHERE `FileDay` = 20131220"
Set rs = cn.Execute(srtQry)
tmpArray = rs.GetRows
cn.Close
tmpArray2 = TransposeArray(tmpArray)
End Sub
TransposeArray:
Public Function TransposeArray(InputArr As Variant) As Variant
Dim RowNdx, ColNdx, LB1, LB2, UB1, UB2 As Long, tmpArray As Variant
LB1 = LBound(InputArr, 1)
LB2 = LBound(InputArr, 2)
UB1 = UBound(InputArr, 1)
UB2 = UBound(InputArr, 2)
ReDim tmpArray(LB2 To LB2 + UB2 - LB2, LB1 To LB1 + UB1 - LB1)
For RowNdx = LB2 To UB2
For ColNdx = LB1 To UB1
tmpArray(RowNdx, ColNdx) = InputArr(ColNdx, RowNdx)
Next ColNdx
Next RowNdx
TransposeArray = tmpArray
End Function