![]() NOTE: the Open Connection Section, this will need to be manually changed to your SQL Server, Database and Login details. ![]() Right click on the “Microsoft Excel Objects” Select “insert” -> “Module”Ĭopy and paste the below code into the Module. Scroll down and tick the latest “Microsoft ActiveX Data Objects” at present this is the 6.1 Library. This opens the VB, Select Tools -> References Once you have the Developer Ribbon Select it and then Select “Visual Basic” Go to the Developer Tab, If you dont have a Developer tab go to File -> Options (this opens the Excel Options Tab) Select the Customize Ribbon – and Then Tick the Developer checkbox on the Customize the Ribbon Main Tabs”. Name “Sheet1″ as “Data” and Create a second Sheet called “Request” ![]() There are loads of ways to Export SQL Server data to Excel, but I am always on the hunt for better and easier ways and VBA seems a good option to explore!īelow are the steps to build a VBA Excel spreadsheet that connects to SQL Server data and loads the data into a worksheet:Ĭreate a New “Blank workbook” and Save it as a “Excel Macro-Enabled Workbook (*.xlsm)”, name it what you like. ![]() This is the first in a series of posts, where I’ll be building out from this first attempt of using VBA to load data into Excel from SQL Server. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |