Friday, 15 June 2012

Model View Controller (MVC) implementation in Excel VBA

With this post I would like to illustrate the concept of Model View Controller (MVC) design pattern implemented in excel VBA with a simple and easy to understand example.

The model view controller design pattern has a benefit which provides separation of concern objectively while designing the solution. With this technique in hand, the data is modelled as an object and the form in which is represented is also modelled as object with relevant functions provided for the operations required, which is orchestrated by a controller class.


The attached example is a crude implementation of MVC a quick attempt of mine to achieve the same, though I do accept that this piece of code is far from perfection and has still room to improve upon.


The workbook has simple worksheet which on one side has form to display the data (left) and on (right) a table storing multiple values for the same. The workbook has two functionalities provided to get the relevant data based on the serial number provided and update functionality to update the corresponding the record.


Please check the workbook VBA code for MVC implementation details.


Download Solution
Download solution



Osita Okonkwo said...

Thanks for the example Amol! I've been searching for a simple approach to implementing MVC for an Access project that will be later moved to Web/.NET. Your post and code was VERY helpful!!

Thanh Le Ngoc said...

Thanh Le
Thanks for your post !
It's greate.