Resource Logic Client/Server Development Services
Microsoft Excel Visual Basic for Applications (VBA) Demonstration
This spreadsheet should be downloaded, then opened in Excel. There is no point
in having the browser open while the spreadsheet is run, but no harm in it either.
Anti-virus programs will alert the user to the fact that this spreadsheet contains a macro.
The macro is activated by pressing Ctrl-Shift-T (for Timesheet). A form appears
on the spreadsheet asking for a month and a year (separate fields). Enter a
year between 2001 and 2005. Enter a month between 1 and 12.
If Macro Security in Excel is set to high, macros don't run. It is recommended
that the user set it to medium. In this situation, the user is warned that a
spreadsheet contains a macro, and would the user like to have it enabled. To run
this demo, open the spreadsheet. Click 'Enable Macros' in order to run the code
behind this spreadsheet.
The 'Populate' button renders a timesheet from ranges A10 to A40. Column 1 contains a date.
Columns 2 through 6 are 'blank', although they have a boundary given to them by the
program. Rows that are 'weekends' (Sunday or Saturday) are given a gray background.
The 'Hide' button hides the form without executing anything else.
This demo is intended to acquaint a user or developer with the basic mechanisms of VBA
in Excel. To bring up the VBA Project, select 'Tools' -> 'Macro' -> 'Visual Basic Editor'.
This will open the VBA developer studio, listing the forms, macros, and other objects
associated with the VBA project.
Double-click on PopulateTimeSheet form to view the form. From the View menu option, select
'Code' to look at the code.