I'm trying to populate individual cells with function calls to a macro similar to how one would use a regular function to populate a cell. My function is:
Public Function getHours(item As String,high As Number) As Double
Sheets("Work Items").Select
numRows = ActiveSheet.Rows
getHours = 0
For i = 2 To numRows
if Cells(i,2).value= item Then
if high = 1 Then
getHours = getHours + Cells(i,6).value
else
getHours = getHours + Cells(i,5).value
end if
end if
Next i
End Function
Where I pass a cell value and constant to return a double. However, whenever I try to use the function, it doesn't come up as an option when I type = into the cell, and when I type out the arguments like "=getHours(a3,0)", it re-formats to "=GETHOURS(A3;0)" and gives me a #NAME! error. Even if my code isn't correct, it doesn't seem like using macros in this fashion even works in Sheet.
My function doesn't show up on the manage tab for macros, but when I try to create a new macro with the same name it says that it already exists.
If using a macro isn't possible, could I be assisted with an alternative method?
Thanks.