I defined a few functions in a workbook using VBA, and then expected to be able to use them in a cell formula - but Excel does not recognise the function. I just get #NAME?<
XLSX file and XLSM files have nothing to do with it. Format plays the role when you save the file. (In XLSX, VBA code will be stripped while saving the file).
The below code from http://office.microsoft.com/en-us/excel-help/creating-custom-functions-HA001111701.aspx works quite well inside a new module in my excel.
Function Discount(quantity, price)
If quantity >= 100 Then
Discount = quantity * price * 0.1
Else
Discount = 0
End If
Discount = Application.Round(Discount, 2)
End Function
Given that I cannot see your code, can you try whether below function works for you too? If so, start modifying the below function so that it becomes your function (for example, first change the name and see if it works, and then change number of parameters and check if it works, and then change name of parameters).