defining a database in VBA

davers5

Active Member
Joined
Feb 20, 2002
Messages
255
I have a VBA procedure that performs a query on a database in excel using ADO. If I define the database beforehand using MS Query the procedure works. However, what I'd like to do is define the database object (using a range) in an earlier procedure. If I have a range of cells in Excel that I want to be a database, how do I make this range a database object?

Thanks for the help,

Dave S.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Actually, I don't need to create a whole database, just a table. I think there's something called a Tabledef object but I can't figure out how to define one from an excel range. Any suggestions?

Dave S.
 
Upvote 0
XL doesn't support a database object. It is possible for MS provided Jet/ODBC drivers to interpret any named range as a table. By convention, the first row of the named range contains the field (column) names. To name a range, use Insert | Name > Define... To get the VBA syntax, turn on the macro recorder (Tools | Macro > Record new macro...), name a range by hand, and turn off the recorder.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,700
Members
448,979
Latest member
DET4492

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