Question : Calling a Function from another Function VBA Excel

I'm trying to call a function from another function.  Do I need to assign the call to a variable or something first?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
Function RevenueBucket(month)
RevenueBucket = Application.WorksheetFunction.VLookup(month, Sheets("tables").Range("F:G"), 2, 0)
End Function

Function WhatCorpTable(month)
Call RevenueBucket(month)
WhatCorpTable = Application.WorksheetFunction.Match(RevenueBucket, Sheets("Corp-TableGraph").Rannge("A:A"), 0)
End Function

Answer : Calling a Function from another Function VBA Excel

You need to either assign the result of the function to a variable, or pass the parameter in the call.

So you could do it like this....

Function WhatCorpTable(month)
   Dim RevBucket As Variant
   RevBucket = RevenueBucket(month)
   WhatCorpTable = Application.WorksheetFunction.Match(RevBucket, Sheets("Corp-TableGraph").Rannge("A:A"), 0)
End Function

...or like this...

Function WhatCorpTable(month)
   WhatCorpTable = Application.WorksheetFunction.Match(RevenueBucket(month), Sheets("Corp-TableGraph").Rannge("A:A"), 0)
End Function

Wayne
Random Solutions  
 
programming4us programming4us