Hi there,
See if the following code does what you need - it will enter a value of zero in the Average Cell if none of the tested cells contain the required value:
The highlighted values can be altered to suit your own requirements.
I've made some changes to your code:
(a) The Range references are now fully qualified - this means that the code is independent of whichever worksheet happens to be active
(b) The no of rows to be conditionally averaged is specified by the value of the Constant lMAXIMUM_ROWS - it is not very efficient to require Excel to conditionally average almost one and a half million rows each time.
Hope this helps - please let me know how you get on.
Regards,
Greg M
Bookmarks