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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

davers5

Active Member
Joined
Feb 20, 2002
Messages
255
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.
 

tusharm

MrExcel MVP
Joined
May 28, 2002
Messages
11,029
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.
 

Forum statistics

Threads
1,148,045
Messages
5,744,489
Members
423,880
Latest member
CRE_finance_guy

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
Top