ADODB transpose without array?

Jaymond Flurrie

Well-known Member
Joined
Sep 22, 2008
Messages
921
Office Version
  1. 365
Platform
  1. Windows
When I pull out data as an ADODB recordset, it's transposed to have fields in rows and records as columns. When we speak about small amount of data (like dozens times dozens), there's no problem, just use something like
Code:
    'Check to make sure we received data
    If Not rsData.EOF Then
        vFromMySQL = WorksheetFunction.Transpose(rsData.GetRows(rsData.RecordCount))
    End If
where the key naturally is WorksheetFunction.Transpose.

But since I have 50 x 100 000 = 5 million elements, WorksheetFunction.Transpose falls short.

Plain and simply: What can I do?
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
The best solution I've found so far is plain and simply to copy the array element by element to another array by swapping the rows and columns. Fast? Not really. Works? Yes.
 
Upvote 0
I wonder if I'll make up my mind tonight. It does work, here:

Code:
    'Check to make sure we received data
    If Not rsData.EOF Then
        vFromMySQL = rsData.GetRows(rsData.RecordCount)
    End If
    
    ReDim vTransposed(LBound(vFromMySQL, 2) To UBound(vFromMySQL, 2))
    
    For L = LBound(vFromMySQL, 2) To UBound(vFromMySQL, 2)
        vTransposed(L) = vFromMySQL(0, L)
    Next L
 
Upvote 0
If you need it as an array, why do you need to transpose it?
 
Upvote 0
If you need it as an array, why do you need to transpose it?

Good question. It's just that everytime I've seen this used before it has been transposed.

Got to love these "What in the world are you doing!?" replies - Especially when you have a great point! :rofl:
 
Upvote 0
It's usually transposed because it's going to end up on a worksheet. Most of the time CopyFromRecordset is easier for that.
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,443
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top