1. A basic function is meant to return a single value to a single cell in the worksheet (the cell containing the function).
2. The function must have a line that assigns the calculated value to the cell containing the function. In the function CubeRt()
3. In your function, you have the line: MonthFromDt = Month(DateSerial(yr, 1, 1) + 7 * (wk - 1)) which should return the calculated month to the cell.
The function should have ended with that line; instead, it is followed by the line:
Range("AO" & CStr(k)) = MonthFromDt
You are trying to write the month to a series of cells (2060 cells!) in the worksheet using a loop.
What it is actually doing is trying to call the function from within the function itself (it's called recursion).
The function requires a string to be passed to the variable "s" but you are passing nothing so the program crashes.
The function should look like:
I don't know why you need the vb function, it can be done directly in the cell using:
Bookmarks