January 6th, 2006, 1:01 pm
sllim,The attached spreadsheet should set you on the way. It connects to an Oracle db via ado, iterating through a couple of (dodgy) SQL statements. You'll need to modify the code slightly to connect to sybase, (I think substituting "oraOLEDB.Oracle" with "Sybase ASE OLE DB Provider" should do it). Essentially though, it should give you an idea of how to query a db from excel with relative autonomy. I put together a function to handle populating the worksheets from the recordset, because I originally couldn't find a simple way of dumping the data directly from a recordset. There is probably a better way, but I haven't bothered to change it as this works for my purposes. It also allows you the option of printing the sql that produced the data at the bottom of the worksheet - always useful when you want to know how you got the data three months later!You'll also need to turn on the Activex data objects and ole db references under the Tools|References menu in the VBA menus.