| DatabaseLessons.com |
'Serving the Microsoft® Access |
|
|
Sending MS Access Data to Excel - Part 5A reader wrote and asked, "How can I create a 'totals' line in the Excel output?" Good question. First, let's remind ourselves how Excel does it normally. Open an existing Excel workbook that has a Totals line, or quickly create one. Here is what shows up in the formula bar when I point to a cell with a total in it. =SUM(C10:C34) Now that we know what it should look like, it's quite easy to create a totals cell based on a variable height column. The key is to keep track of what row you are on. NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here. Remember, this code will only work if you have Excel references turned on. The References section is found under the Tools menu in the VBA editor. See the above mentioned article on DAO for more details on the References menu. Also, I have left out a lot of code, as the first 4 articles in this series should have you to the point where you understand the missing parts.
Note that there are 3 parts to the creation of the total formula.
Thus, if the iRow counter has the value '33' in it at the end of the loop, then the formula created by the above code will be =SUM(C10:C34) and this will be placed in cell C35 Entire series ...
|
|
|
© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. - Privacy Policy |