mdmackillop
11-28-2007, 12:21 PM
http://vbaexpress.com/forum/showthread.php?t=16377
Re this question, I thought a simple UDF would suffice. I'm getting a "wrong" result with a Function, but correct answer with a Sub. Any ideas?
Sub CountJ1()
Dim r As Range
Set r = Range("J:J").SpecialCells(xlCellTypeConstants, 1)(1)
Selection = Application.Sum(Range(r, r.Offset(Range("U17")-1)))
End Sub
Function CountJ()
Dim r As Range
Set r = Range("J:J").SpecialCells(xlCellTypeConstants, 1)(1)
CountJ = Application.Sum(Range(r, r.Offset(Range("U17")-1)))
End Function
Re this question, I thought a simple UDF would suffice. I'm getting a "wrong" result with a Function, but correct answer with a Sub. Any ideas?
Sub CountJ1()
Dim r As Range
Set r = Range("J:J").SpecialCells(xlCellTypeConstants, 1)(1)
Selection = Application.Sum(Range(r, r.Offset(Range("U17")-1)))
End Sub
Function CountJ()
Dim r As Range
Set r = Range("J:J").SpecialCells(xlCellTypeConstants, 1)(1)
CountJ = Application.Sum(Range(r, r.Offset(Range("U17")-1)))
End Function