Rs.Open strSQL, cnn, adOpenKeyset, adLockOptimistic StrSQL = "Select Distinct From Order by " When you click on the Update Drop Downs button, the VBA code uses the “Data” worksheet as a table and then finds unique values for Products, Region and Customer Types and then populates them as ListItems for the ComboBox controls. On this line, we define all the possible file extensions that we are allowed to create an Excel Workbook and then use as our database. If cnn.State = adStateOpen Then cnn.CloseĬnn.ConnectionString = "Driver= DBQ=" & _ĪctiveWorkbook.Path & Application.PathSeparator & ActiveWorkbook.Name Once this is done we need to hit the road with some VBA code. I usually select the most recent version, however if you are developing a product it will be best suited if you are familiar with the operating system and office version used by the end-user’s system and accordingly select the best version available. You can do this from Visual Basic Editor > Tools. We need to add a reference to the Microsoft ActiveX Data Objects Library to be able to use the worksheet as a database table. We will also use another SQL statement to populate the top right hand side table for calls data when all the 3 drop downs have some options selected. Once the user clicks on Show Data we will use a SQL statement to filter-out the data as per the drop down options selected by the user and the put them in the table below. We need some raw data and we will utilize Customer Service Dashboard sample database here.įirst we will design the structure of what all option we want to present for filtering the data, which you can see in the interface below. If you know SQL (Structured Query Language) your task becomes much easier.This has nothing related with the in-built Table (2007 and greater) / List (2003 and previous) feature of Excel.The entire sheet (where the raw data has been stored) will be referred as one single database table by Excel.Today we will learn how to use Excel as a Database and how to use SQL statements to get what we want. Eventually they start using Access or SQL Server etc. People spend a lot of time thinking whether to use Excel as their database or not. Often I have thought, if I could have write “Select EmployeeName From Sheet Where EmployeeID=123” and use this on my excel sheet, my life would be simpler. This is a guest post by Vijay, our in-house VBA Expert.
0 Comments
Leave a Reply. |