Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture Roger Sutton CO357 Computing for Business and Accounting 13: Automation and Control (Macros and Form controls ) 1.

Similar presentations


Presentation on theme: "Lecture Roger Sutton CO357 Computing for Business and Accounting 13: Automation and Control (Macros and Form controls ) 1."— Presentation transcript:

1 Lecture Roger Sutton c.r.sutton@kent.ac.uk CO357 Computing for Business and Accounting 13: Automation and Control (Macros and Form controls ) 1

2 CO357 Computing for Business and Accounting Automation Within a spreadsheet automation can be performed a variety of ways: E.g. 1.By the spreadsheet’s re-calculation on changing a cell’s contents - making use of the interdependence of the cells 2.Using the If-function – values appear in cells depending on the value of some other cell or formula 3.Using conditional formatting – can be used to suppress displays and hence output 4.Using macros 2

3 CO357 Computing for Business and Accounting Movement between Worksheets Generally a user moves to another sheet by clicking the required sheet tag in the left hand corner above the task bar. However, when software has been created for other people to use such tags, tool bars, row and columns headers, etc. are removed. (see Excel Options|Advanced|Display options Movement between sheets may then be achieved using hyperlinks or buttons. 3 By hyperlink, a label is entered, then Hyperlink selected from Insert|Links to reveal the adjacent dialog : Selecting ‘Place in this document’ allows the required worksheet to be identified.

4 CO357 Computing for Business and Accounting Use of IF-function The IF function can be used to detect when cells contain particular values or no value and then perform the required action or display in response. Conditional formatting can be used to determine how results are displayed if at all. 4 co357lec08

5 CO357 Computing for Business and Accounting Macros A macro is a set of instructions or commands that has been recorded so that the same sequence of actions can be reproduced comparatively easily. A macro is used to automate tasks that are:  repetitive  time-consuming, or  error-prone In Excel, macros are expressed in Visual Basic or VBA (Visual Basic for Applications) and saved in a special macro worksheet. To create and use macros it is necessary to ensure the Developer tag is shown in the ribbon – this is achieved by ticking the appropriate checkbox in Popular of Excel Options. 5

6 CO357 Computing for Business and Accounting Creating the Macro Macros may be run either from  a special button,  a menu choice, or using  a short-cut key. A macro is created by demonstrating what is required so that a record can be made. It is recommended that you run through the intended operation a few times to ensure that all steps are included and then write these steps down on paper. 6 Record Macro from Developer |Code reveals: Enter a name and letter for shortcut key. Once OK is clicked all subsequent key strokes are recorded until the Stop recording button in the Developer |Code panel is clicked.

7 CO357 Computing for Business and Accounting Example: creating a pie chart 1.Click Chart icon from Insert | Charts 2.Select Pie from 2-D options 3.Click Select Data from Design|Data 4.Identify chart data range: C5:C9 5.Edit Series1 6.Identify series name: B2 7.Edit the Horizontal Axis Labels, then supply labels B5:B9. 8.Click Ok twice 9.Click Chart Labels from Layout | Labels 10. Select Centre, then More Data Label Options 11. Tick Percentage and then deselect Value (in that order!) 12.Make cell A1 active and then click Stop Recording from Developer|Code 7 co357lec08

8 CO357 Computing for Business and Accounting To operate macro from a button The set up is a two-stage operation: 1.Create the button: The button labelling can be changed by holding down the Ctrl key and clicking the button. Highlight the existing label and type in that required. 8 Select Button from Developer|Controls|Insert|Form Controls Drag mouse pointer to cover cells to be occupied by the button and release. This gives rise to the dialog: 2.Assign the macro The dialog provides an opportunity to assign an existing macro or record a new one

9 CO357 Computing for Business and Accounting Form Controls 1.Spinner (Scroll bar) Often an input value may be one of a numerical series and it is intended that the user be allowed to examine as the input value is increased or decreased. 9 co357lec08 Spinner: Repayment period can be varied by 1 from 1 to 18 months

10 CO357 Computing for Business and Accounting Spinner –cont’d The Spinner control is obtained from Developer|Insert|Forms Controls 10  Drag mouse pointer over cells to be occupied by spinner and release to obtain:  Use right click and select Format Control to reveal:  Specify minimum and maximum values, and the incremental change  Indicate the ‘link cell’, i.e. the cell to contain the resulting value. co357lec08

11 CO357 Computing for Business and Accounting Combo box 2. The Combo box allows a value to be selected from a column of possible values: 11 Combo box: ‘Amount borrowed’ is selected from a restricted column of values

12 CO357 Computing for Business and Accounting Combo box – cont’d Once the control has been introduced onto the worksheet it is formatted using the following dialog: =index( $O$7:$O$26, $O$6) 12  Specify the range that contains possible values.  Indicate where the index of the chosen value will be stored.  Indicate how many lines at a time will be shown in the list.  To retrieve the chosen value requires the formula:

13 CO357 Computing for Business and Accounting Radio (option) button 3.The radio button operates like a button in that it may be assigned a macro and this is invoked when the button is clicked. Radio buttons may also be grouped together using the ‘Group‘ control such that when one button is selected, all the others in the group are deselected. 13 Using Format control, a link cell is identified to hold the count/index of the option button selected (The count is assigned when the button is created).

14 CO357 Computing for Business and Accounting Check box Like other buttons, ticking a checkbox can initiate an assigned macro. Further, whereas radio buttons allow one option to be chosen from a group, several check boxes enable a combination of choices to be identified and acted upon. 14 Using Format control, a link cell is identified to hold the Boolean value TRUE if the box is checked otherwise FALSE.


Download ppt "Lecture Roger Sutton CO357 Computing for Business and Accounting 13: Automation and Control (Macros and Form controls ) 1."

Similar presentations


Ads by Google