GetRows to Array

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,958
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
I have opened a recordset to 2 fields in my table and applied GetRows.

The result is

Image5.jpg


How could I best get field 1 into a 1 dimensional array and field 2 into another 1 dimensional array ?
The reason is to Filter them and that needs a 1 dimensional array.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
GetRows has an argument that lets you specify the field/fields you want to return.

Why not use that?
 
Upvote 0
What is it ? F1 no longer gives me Help, but some annoying online thing (since 2007). Think I'll have to install Office 2003 on the laptop to get it back.
 
Upvote 0
Off the top of my head there are 3 arguments for GetRows - rows, start and fields.

The first two determine the no of rows to return and which row to start from.

Fields specifies the, well fields to return, and can be either a single value for a single field or an array for multiple fields.
 
Upvote 0
Norie, I can't find anything like that for Getrows. Only one argument - number of rows.
 
Upvote 0
You're in a database - why use filter on an array? Use "WHERE" with a query!
 
Upvote 0
xenou

Good point, didn't actually realise this was in th Access section so assumed the OP was working in some other application.
 
Upvote 0
Another good option is to grab the data in a recordset, which also has filter functions.

As far as transforming 2d arrays to 1d arrays, I think the best (and only) method I know of is to create a new array and populate it. This sounds like a lot of work but in fact it only takes one pass so it's very quick even with hundreds of thousands of records. You can redimension some arrays but I think the arrays returned by getRows aren't good for that - you can only remove the last dimension which is probably the one with all your data in it!
 
Last edited:
Upvote 0
xenou

If this thread was in the Excel section, which is where I originally thought it was, I would be pointing the OP towards Application.Transpose.
 
Upvote 0

Forum statistics

Threads
1,221,889
Messages
6,162,624
Members
451,778
Latest member
ragananthony7911

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