I am very new to VBA and have written a function that returns a number from a range. My issue is that I want to write several other similar functions and the use the Call command to return the results of the functions. However, when I try to call the function I have already written (which works on its own) the result that shows up when I test it is 0.
Can anyone help by letting me know what I am doing wrong and how to fix it? Here is the first function I have written:
However, when I try to Call it using:
The result always returns a value of 0 instead of the number in the range the Called function should reference. My ultimate goal is to call several similar functions at the same time.
Any advice would be much appreciated!
Can anyone help by letting me know what I am doing wrong and how to fix it? Here is the first function I have written:
Code:
Function B02SP8(grade, step)
If grade = "B02" And step = 1 Then
B02SP8 = Sheets("Sheet2").Range("F55")
ElseIf grade = "B02" And step = 2 Then
B02SP8 = Sheets("Sheet2").Range("G55")
ElseIf grade = "B02" And step = 3 Then
B02SP8 = Sheets("Sheet2").Range("H55")
ElseIf grade = "B02" And step = 4 Then
B02SP8 = Sheets("Sheet2").Range("I55")
ElseIf grade = "B02" And step = 5 Then
B02SP8 = Sheets("Sheet2").Range("J55")[/INDENT]
[INDENT] Else
B02SP8 = "Grade/Step not included in function"
End If
B02SP8 = Application.Round(B02SP8, 2)
End Function[/INDENT]
[INDENT]
Code:
Function HR(grade, step)
Call B02SP8(grade, step)
End Function
The result always returns a value of 0 instead of the number in the range the Called function should reference. My ultimate goal is to call several similar functions at the same time.
Any advice would be much appreciated!