Consuming OData with Office VBA – Part III (Excel)

This is part three of a series - you should read part I and part II to have the code snippets handy and follow along.

Today we won't be doing anything special with OData itself, instead we'll see how the snippets work across different Microsoft Office products. Just start up Excel, paste in the OData import code, and add the following snippet.

This code will import the dataset with bank locations from the District of Columbia, available through the OGDI site. It puts them into the current spreadsheet, then creates a PivotCache and PivotTable over that data, showing you how many locations are on file for each bank. The code to create the pivot tables should work on Excel 2007 up; the syntax to create this on a previous version should be a bit different, but you can try commenting that section out. Or you can record a macro while doing it manually and let Excel tell you how to write the code.