Money Macro

This VBA macro steps through Excel and reformats the data in a way that makes it easy to import into Access so that you can use it to build a cube.

Russ Whitney

June 16, 2003

2 Min Read
ITPro Today logo in a gray background | ITPro Today


To use the Visual Basic for Applications (VBA) macro I created to work with either the Microsoft Money sample file or your own financial data, open the "Downloads" file above. Open the Sample.xls file, and in the Microsoft Excel Tools menu, select Macro, Visual Basic Editor. Inside the editor, right-click the project on the left called VBAProject (Sample.xls), and select Import File. (Note that if you click Export To Excel in Money, which launches Excel with the Sample.csv file, then go into VBA, you'll see the project name as Sample.csv.) Next, select the MSMoneyHelper.bas file. After you import the macro, open the Visual Basic Editor's Run menu, and select Run Macro. Choose the macro named ProcessMoneyData, and click Run. After the macro has finished executing, you can save the Excel file as Sample.xls and import it into Microsoft Access.

If you don't have the VBA macro that I created or you want to use another extraction, transformation, and loading (ETL) method to perform similar steps, here are the specific formatting tasks that my macro performs:

  1. Delete the first six title rows at the top of the file.

  2. Reformat column B in date format.

  3. Insert three columns in front of the Amount column and name them Subcategory, Action, and Security.

  4. Begin stepping through the rows of data, and perform the following steps:

    1. If the row is blank, delete it.

    2. If the row is part of a split transaction, duplicate the date, payee, and account from the previous row of the same split transaction.

    3. Delete the first row of a split transaction. (The first row is just a subtotal of the subsequent rows. If you import the first row, you'll be duplicating data.)

    4. Split the category field into category and subcategory and separate them with a colon.

    5. If the memo contains information about an investment transaction, create separate action and security fields.

    6. Fill any empty fields with "(none)."

    7. Delete the last two rows of the report because they don't contain valid data.

I'm not a VBA expert, but I do know an important trick that you can use for creating VBA macros: If you want to know how to perform an Excel task in VBA, pull down the Tools menu and select Macro, Record, New Macro. Perform the task that you want to record in Excel and end the macro. You can then enter the Visual Basic Editor and inspect the macro that Excel created.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like