Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
463 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Posted by Andrew Gould on 07 May 2021
This video explains how to use the GetRows method of an ADODB recordset to write data into an array.
See our full range of VBA training resources, or test your knowledge of VBA with one of our VBA skills assessment tests.
This video has the following accompanying files:
File name | Type | Description |
---|---|---|
ADODB Recordset into Array COMPLETED.xlsm | Excel workbook with macros | |
ADODB Recordset into Array.xlsm | Excel workbook with macros | |
Movies.xlsx | Excel workbook |
Click to download a zipped copy of the above files.
There are no exercises for this video.
You can increase the size of your video to make it fill the screen like this:
Play your video (the icons shown won't appear until you do), then click on the full screen icon which appears as shown above.
When you've finished viewing a video in full screen mode, just press the Esc key to return to normal view.
To improve the quality of a video, first click on the Settings icon:
Make sure yoiu're playing your video so that the icons shown above appear, then click on this gear icon.
Choose to change the video quality:
Click as above to change your video quality.
The higher the number you choose, the better will be your video quality (but the slower the connection speed):
Don't choose the HD option shown unless your connection speed is fast enough to support it!
Is your Wise Owl speaking too slowly (or too quickly)? You can also use the Settings menu above to change your playback speed.
From: | nielsjmp |
When: | 02 Jul 25 at 20:26 |
Hi, thanks a lot for the tutorials. Im quite new in VBA but have used it to open data from a closed workbook containing a database with around 35 columns and some 15000 rows.
But I run into one weird problem that it took me some time to sort out. In my column no 13 I have some long text strings, worst case I think they can be up to 5000 characters. The recordset ("TableArr()") seems to be truncated to 255 characters. Is there a workaround on this, eventually specify the 13th column to be separately uploaded to an array with specified longer text strings?
I hope the question makes sense! Thanks again:-)
Dim Conn As ADODB.Connection
Dim PartNoRecordSet As ADODB.RecordSet
Dim DwgRecordSet As ADODB.RecordSet
Dim TableArr() As Variant
Dim RevNo As String, PartNo As String ', FirstRow() As String,
Dim PartNos() As String
Dim i As Long, j As Long, IdxDwgRev As Long, IdxPartNo As Long, NoOfRows As Long, NoOfCols As Long
ReDim PartNoDataBaseStr(1, 1)
ReDim FirstRow(1)
ReDim PartNoArr(1)
Set Conn = New ADODB.Connection
Set PartNoRecordSet = New ADODB.RecordSet
SheetName = "PartNoDB"
Conn.ConnectionString = _
"Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & DataBaseDir & "\" & DatabaseFile & _
";Extended Properties='Excel 12.0 Macro;HDR=NO';"
PartNoRecordSet.ActiveConnection = Conn
PartNoRecordSet.Source = "Select * from [PartNoDB$]"
TableArr = PartNoRecordSet.GetRows 'TableArr includes Null values
NoOfCols = UBound(TableArr, 1)
NoOfRows = UBound(TableArr, 2)
ReDim PartNoDataBaseStr(NoOfCols, NoOfRows)
ReDim FirstRow(NoOfCols)
ReDim PartNoArr(NoOfRows)
'Cleaning up for Null values
For i = 0 To NoOfCols - 1
For j = 0 To NoOfRows - 1
If IsNull(TableArr(i, j)) Then
PartNoDataBaseStr(i, j) = vbNullString
Else
PartNoDataBaseStr(i, j) = TableArr(i, j)
End If
Next
Next
For i = 0 To NoOfCols - 1
FirstRow(i) = PartNoDataBaseStr(i, 0)
Next
For j = 0 To NoOfRows - 1
PartNoArr(j) = PartNoDataBaseStr(0, j)
Next
From: | Andrew G |
When: | 04 Jul 25 at 11:57 |
Hi!
I'm unable to replicate this problem although Google suggests you're not the only one experiencing it.
You could try adding a MAXSCANROWS extended property to your connection string to force it to look at every row of data to determine the data type.
See the answer here for more information https://stackoverflow.com/questions/54173345/problems-reading-doubles-from-csv-vba
I hope it helps!
From: | nielsjmp |
When: | 07 Jul 25 at 12:46 |
Hi Andrew, thanks for your efforts and your reply!
I have made a test-example, which can be found on
It doesnt look like I can attach a file here, theres an example at the excelforum.
If you cant replicate it, it might be machine dependant, there might be a setting somewhere(?)
Thanks again - Niels
From: | Andrew G |
When: | 10 Jul 25 at 07:17 |
Hi Niels!
I'm not aware of a machine-specific setting which controls this. I'm not sure what else to suggest here, I'm stumped!
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2025. All Rights Reserved.