Retrieve mulitple fields as one result

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,835
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Is it possible to extract either all columns or a range of columns (e.g 25 to 255) from a table as one result ?
Or a method to concatenate each field (without looping through one by one ) ?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I've been using the query design grid for testing, but eventually it will be sql in VBA.

e.g.
Set t = db.OpenRecordset("Select * from tblTest;")

Then I can return t(0), t(1), etc.

But the wanted result is t(25) & t(26)..... & t(255)
I'm hoping there's an alternative method to avoid building up via a loop.
 
Upvote 0
Not that I am aware of sorry - I don't think you can avoid using a loop. Even if you assigned it all to one variable it would end up being an array of results much like you have indicated, which would still require a loop to process. Is there any reason you want to avoid using loops?
 
Upvote 0
Only that it might have been quicker, and more compact code.
The loop is pretty quick though.
Thanks for replying. :)
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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