Macro to read data from Table

Hi All,

Does any one has any sample code to read data from a table in the database and save it to Excel? The table has 4 columns.

Thanks…


JohnJustus :us: (BOB member since 2007-06-25)

Hi,

This depends on the database that you use. The code for connecting to a database and selecting records is different for different databases.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

True Marek, Any sample code available perhaps, If I get the code, then I can replace the code related to my database (Connection and selecting records )where required.
Thanks…


JohnJustus :us: (BOB member since 2007-06-25)

Why reinvent the wheel? :slight_smile:

Build a universe for the data you need. Build a report. Then you can still use VBA to automate the execution of that report and the saving to Excel…


Dave Rathbun :us: (BOB member since 2002-06-06)

Thats true and corect Dave.
I am trying to find a script to fetch some other information from the table and not related to reporting data and again use that information to calculate data on a model with some business rules.
I have code for all other part and the one thing I am missing is fetching the information from the table.
Thanks…


JohnJustus :us: (BOB member since 2007-06-25)

Hmmm…

I echo Dave’s sentiments - it seems as though you have a recipe for a micro-application that can be written using BO: “model” = Universe, “business rules” = report-level computations/formulae, “excel” = export/schedule/save as.

In any case, there are numerous links that provide information on your core need as described:

http://www.excelguru.ca/node/23

Good luck


Atul Chowdhury (BOB member since 2003-07-07)

Thanks Atul. Good Idea. lemme do some R&D based upon the requirement.
BTW, I checked the link and I belive it will be useful.
Thanks…


JohnJustus :us: (BOB member since 2007-06-25)