1 Copy the SALESMAN.XLS worksheet from the Website. The weeklysales worksheet is protected apart from the Week Sales input area. Perform the following tasks. Create a new macro using Tools > Macro > Macros Enter the procedure as shown on Listing 3.4 (page 60). Make sure that the code is written exactly as shown, otherwise you will get error messages. Now do the following:

a) Run the procedure from the VBA editor by clicking the Run button on the Standard toolbar. Check the program works correctly by choosing: File > Close and Return to Microsoft Excel, alternatively, you can click the Excel icon on the Windows Taskbar.

b) Run the program from the weeklysales worksheet (you might like to input some test data into the week_sales named range because it will be empty if the procedure worked correctly from part (a).

c) Create a button on the weeklysales worksheet and assign the name Updatesales to it. Click on the button to run the procedure.

2 Design, using structured English pseudocode, a VBA sub procedure that will prompt the user to input a number representing a person's salary and then respond with a message box containing the message "Thank you". Now write the VBA code from the design.

3 Open a new workbook. Using the default Sheet1, enter the following macro using the VBE:

Sub ifGreaterThanTen()

theAge = InputBox("Please input a number representing an adult age") If theAge < 18 Then

MsgBox "Invalid data. An Adult is over 18" End If End Sub

Explain what you think this program may be doing. Run the macro and check, using the data given to see that it works properly.

4 Introduction to objects

Object-oriented programming . . . . 68

Object collections 71

The Excel object model 75

The Object Browser 77

Referencing named ranges 84

Exercises 89

0 0

Post a comment