hi,
I have written the following code in a module which is:
Function CntShts()
Application.Volatile
CntShts = ThisWorkbook.Sheets.Count - 1
End Function
In the cell a2 I have written =CntShts()
However, I get a different value in cell a2, everytime, i.e., "#ref", "#value" or the answer( a number). When I rewrite the function in another cell, then the actual value is displayed in cell a2. Why is this so? Please help.
I have written the following code in a module which is:
Function CntShts()
Application.Volatile
CntShts = ThisWorkbook.Sheets.Count - 1
End Function
In the cell a2 I have written =CntShts()
However, I get a different value in cell a2, everytime, i.e., "#ref", "#value" or the answer( a number). When I rewrite the function in another cell, then the actual value is displayed in cell a2. Why is this so? Please help.