Lbis82
10-01-2008, 10:38 PM
Function fn_example(varName, varMonth)
Dim varRow1, varRowName1
varRow1 = Application.WorksheetFunction.Match(varName, Worksheets(1).Range("B1:B1000"), 0)
varRowName1 = "B" & CStr(varRow1)
Range("A2").Text = "hello" 'in sheet 2
fn_example = varRowName1
End Function
The above function works like this:
In sheet 1, cell B5 contains the text "Ben" and in sheet 2, A1 contains the formula "=fn_example("Ben", "January")". varMonth is not used in this example btw. When executed, it returned a #value error. Why is this so? I have only utilized a simple range function which I do not see anything wrong with it but the debugger always stops at this line. Can someone please care to advise? Thank you.
p/s: the varRow1 is a no. representing which row "Ben" is in sheet 1 column B.
Dim varRow1, varRowName1
varRow1 = Application.WorksheetFunction.Match(varName, Worksheets(1).Range("B1:B1000"), 0)
varRowName1 = "B" & CStr(varRow1)
Range("A2").Text = "hello" 'in sheet 2
fn_example = varRowName1
End Function
The above function works like this:
In sheet 1, cell B5 contains the text "Ben" and in sheet 2, A1 contains the formula "=fn_example("Ben", "January")". varMonth is not used in this example btw. When executed, it returned a #value error. Why is this so? I have only utilized a simple range function which I do not see anything wrong with it but the debugger always stops at this line. Can someone please care to advise? Thank you.
p/s: the varRow1 is a no. representing which row "Ben" is in sheet 1 column B.