Write a macro that will prompt the user to input a person's name using an InputBox and output the message "TooLong" if the name is longer than 30 characters, otherwise the macro should output the message "Name OK".

Open a new workbook using the default sheetl. Using the cell range C3:C12 enter the following numeric data that represents student examination marks out of 100: 41, 55, 36, 59, 70, 67, 37, 69, 13, 62. Design a VBA macro using structured English pseudocode that will count the number of marks in each category as Distinctions (>=70), Credits (>=60 and < 70) Passes (>=40 and <60) and Failures (<40). From the pseudocode write the VBA macro using the Select Case to implement this program. Output the number in each of these categories using the cells E3: H3 under suitable headings. Open a new workbook and enter the table of data shown below into the cell range A2:J3 into sheet1:

Orange Apple Apple Orange Pear Apple Lemon Orange Pear Lemon Lemon Orange Pears Orange Orange Lemon Orange Orange Apple Apple

Write two separate VBA programs, one that uses multi-way If and the other that uses Select Case statements so that the cell colour is orange if the cell value is "Orange", yellow if the cell value is "Lemon", green if the cell value is "Apple" and blue if the cell value is "Pear".

Design a macro called categoriseMonthSales using structured English for the following task. It should check the value for:

below 0 and 200 then colour the cell green (colorIndex = 31), between 201 and 500 colour the cell yellow (colorIndex=31),

501 to 1000 colour the cell blue (colorIndex=5), above 1001, colour the cell another colour (colorIndex=3).

1 Loops

For... Next loops 132

Exiting a For loop 137

Loop termination 143

Exercises 145

0 0

Post a comment