0% found this document useful (0 votes)
4 views

Lect10

The document outlines the structure and requirements for this year's progress test, which consists of four questions to be completed in 90 minutes. It includes examples of Excel functions and user-defined functions for calculating financial values, minimum and maximum values, and retrieving data using HLOOKUP and VLOOKUP. Additionally, it provides specific command lines and instructions for implementing these functions in Excel.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lect10

The document outlines the structure and requirements for this year's progress test, which consists of four questions to be completed in 90 minutes. It includes examples of Excel functions and user-defined functions for calculating financial values, minimum and maximum values, and retrieving data using HLOOKUP and VLOOKUP. Additionally, it provides specific command lines and instructions for implementing these functions in Excel.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Andreas Fring

There is a small change in style of this years progress test:

• This years progress test has four questions. Three of them


correspond to full marks.
• You have 90 min to answer the questions.

102

! Examples, examples, examples:


1a) Compute the future value of an investment using the Excel
built-in function FV. For an initial deposit of 2500 pounds in a
savings account the bank pays an interest rate of 0.18%. For the
next years you deposit 150 pounds at the beginning (end) of
every month into the account. How much money is in the
account after 5 years. Provide the exact command line for an
Excel built-in function with all its arguments.
=FV(0.18%,60,-150,-2500,1) Ø £12,296.91 beginning
=FV(0.18%,60,-150,-2500,0) Ø £12,279.82 end
- do not forget the %-sign (or write 0.0018)
- even though you pay in you need to write -150 and -2500
- the 60 corresponds to 60 month from 5 years times 12 month
103

Programming Excel/VBA MA1603 1


Andreas Fring

1b) Write down the command line for an Excel built-in function
which produces the function

Use your function to complete the table

- The function can be produced with


=IF(x<=0, SIN(x)-1/8, x^3 -7 *x)
- Just type into the cell B2 and then use the autofill function

104

1c) Write down the functions which are produced by the following
combinations of Excel built-in functions
i) =IF(x<=0, SIN(x)-1/8, x^3 -7 *x)
ii) =IF(Not(AND(x<>1, x<>-2)),”infinity”,1/(x-1)/(x+2) )

i)

ii)

105

Programming Excel/VBA MA1603 2


Andreas Fring

2) Write a user defined function with the name MinAv, which


for an arbitrary number of input variables computes the
minimum, the maximum, the average of the input and
the sum of these three numbers. When the average plus 7 is
smaller or equal than the sum, the function should return the
sum and otherwise the average. Declare all your variables.
Implement your function on an Excel spreadsheet to complete
the following tables:

- As the number of input variables is arbitrary you have


to call the function as MinAv(range) rather than
MinAv(x,y,z) 106

Function MinAv(range) As Single


Dim MA, MI, AV, SU As Integer
MA = WorksheetFunction.Max(range)
MI = WorksheetFunction.Min(range)
AV = WorksheetFunction.Average(range)
SU = MA + MI + AV
If AV + 7 <= SU Then
MinAv = SU
Else
MinAv = AV
End If
End Function
- Row 2: MI=-11, MA=34, AV=9, SU=32
- Row 3: MI=-5, MA=111, AV=39, SU=145
- Row 4: MI=-4, MA=5, AV=0, SU=1
107

Programming Excel/VBA MA1603 3


Andreas Fring

3) Write a user defined function with the name MinMax, which


for an arbitrary number of input variables computes the
minimum and the maximum. When the minimum is negative
the function should return the minimum plus 10 and otherwise
the maximum. Declare all your variables.
Implement your function on an Excel spreadsheet to complete
the following tables:

- You can compute this table easily not even writing the function

108

Function MinMax(range) As Integer


Dim x, y as Integer
x = WorksheetFunction.Max(range)
y = WorksheetFunction.Min(range)
If y < 0 Then
MinMax = y + 10
Else
MinMax = x
End If
End Function
4) For the table below complete the command line and the output.
Then write a function which uses the select case structure and
choses for a country by means of an HLOOKUP table the
capital, the number of inhabitants, the area or the birthrate
depending on whether the second input parameter is “Capital“,
109
“Inhabitants“, “Area“ or “Birth rate“. Declare all variables!

Programming Excel/VBA MA1603 4


Andreas Fring

=HLOOKUP("UK",A1:F5, *,FALSE) Ø 60.3 Mio *=3


=HLOOKUP("New Delhi", * ,4,FALSE) Ø 22.8 * = A2:F5
=HLOOKUP("Great Britain", A1:F6,2) Ø * * = Brasilia
=HLOOKUP("Great Britain", A1:F6,2,False) Ø * * = #N/A
=HLOOKUP("1298 Mio", *) Ø 12.98 * = E3:F5,3
=VLOOKUP("Capital", A1:F5,3,FALSE) Ø * * = Berlin
=VLOOKUP(357021, *) Ø 9595960 * = C1:F5,3
=HLOOKUP(5000000, A4:F5,2)Ø * * = 22.8
=HLOOKUP(*, A1:F5,3,FALSE) Ø 1065 Mio * = "India"
=HLOOKUP("London", A2:F6,*,FALSE)Ø 10.88 *=4 110

Function Cof(Co As String, command As String) As Variant


Select Case command
Case "Capital": Cof = WorksheetFunction.HLookup(Co, [A1:F5], 2, False)
Case "Inhabitants": Cof = WorksheetFunction.HLookup(Co, [A1:F5], 3, False)
Case "Area": Cof = WorksheetFunction.HLookup(Co, [A1:F5], 4, False)
Case "Birth Rate": Cof = WorksheetFunction.HLookup(Co, [A1:F5], 5, False)
Case Else: Cof = "Command not found"
End Select
End Function

111

Programming Excel/VBA MA1603 5

You might also like