AKK
07-20-2009, 12:06 PM
I have written a good bit of VBA, but I am currently trying to write a user defined function for the first time, and I'm having a hard time figuring out to what extent the syntax is different or the same. I need a function that does the following:
Look at all cells from B6 up to the cell that is directly to the left of the cell with the formula in it.
If any of those cells have a numerical value that is not zero, return the value 0.
If all the cells in that range are zero, return the value currently in K6.I haven't really gotten that far yet --
Function SumOnce(rngPrevCells) As Integer
Dim rngPrevCells As Range
Set rngPrevCells = Range("B6", Selection.Offset(0, -1))
'???
End Function
What I'm really having trouble with is figuring out the syntax for that second bullet point I listed. Can anyone help?
Thanks!
Look at all cells from B6 up to the cell that is directly to the left of the cell with the formula in it.
If any of those cells have a numerical value that is not zero, return the value 0.
If all the cells in that range are zero, return the value currently in K6.I haven't really gotten that far yet --
Function SumOnce(rngPrevCells) As Integer
Dim rngPrevCells As Range
Set rngPrevCells = Range("B6", Selection.Offset(0, -1))
'???
End Function
What I'm really having trouble with is figuring out the syntax for that second bullet point I listed. Can anyone help?
Thanks!