Bob,
There's an undocumented difference in the syntax for calling
worksheetfunctions in VBA
This is the official documented syntax:
application.worksheetfunction.MATCH(value,array,ty pe)
In xl97 dropping the application qualifier will give a Compile error,
but in newer versions works similar to the 'official' syntax.
worksheetfunction.MATCH(value,array,type)
However dropping the worksheetfunction qualifier works in all versions
and has a significant advantage: it will not generate a runtime error
if the function returns an errorvalue like #NA
application.MATCH(value,array,type)
Thus you can eliminate the ON ERROR RESUME NEXT lines when you code for
a function that may not yield a valid result. The minor drawback is
that
you wont have intellisense and autocompletion.
I see below you prefer the second syntax.
I (respectfully :) suggest you switch to the third.
--
keepITcool
|
www.XLsupport.com | keepITcool chello nl | amsterdam
Bob Phillips wrote :
Is N10 just an example, this is where the variability might lie?
To get the last row
cLastRow = Cells(Rows.Count,"N").End(xlUp).Row
To sum them
theSum = WorksheetFunction.Sum(Range("N4:N" & CLastRow)
To test D10
With Range("N" & cLastRow+1)
if Range("D10").Value = "" Then
.Value = WorksheetFunction.Sum(Range("N4:N" & CLastRow)
Else
.Value = Range("L" & cLastRow+1).Value + Range("M" &
cLastRow+1).Value
End If
End With