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

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
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,218,887
Messages
6,145,013
Members
450,584
Latest member
Voxov

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