Reputation: 6262
I want to create a wrapper for a formula in Excel,
Let's say something like this:
Function NewToday()
NewToday = Today()
End Function
However when I call it, I get a 'Sub or Function not defined'.
Basically I want to call a normal excel function with supplied arguments inside VBA code
Upvotes: 0
Views: 110
Reputation: 19727
Use Date
instead like this:
Function NewToday() As Date
NewToday = Date
End Function
Upvotes: 0
Reputation: 1561
today
doesn't exists in the VBA Namespace, hence the error. However, you can retrieve any Excel function with Evaluate
which behave like the formula input in Excel.
Function NewToday() As Date
NewToday = Evaluate("today()")
End Function
However you will need to format manually the cell as Date
Upvotes: 1