Hello guys,
Currently I have a set of commands in VBA like:
However, in this averages function, sometimes there is no cell meeting the criteria in averages(), so this 'For next' loop stops when there is no cell meet those criteria.
What I need to do is that this function returns '0' or blank when no cell meets criteria.
I tried this command
but it does not work.
Can you guys please help me out?
Currently I have a set of commands in VBA like:
Rich (BB code):
for n = 1 To 274
port_return.Columns(3).Cells(n).Value = WorksheetFunction.AverageIfs(monthlydata.Columns(2), monthlydata.Columns(3), "=W", monthlydata.Columns(5), "<=0.3")
port_return.Columns(4).Cells(n).Value = WorksheetFunction.AverageIfs(monthlydata.Columns(2), monthlydata.Columns(3), "=W", monthlydata.Columns(5), ">0.7")
Next n
However, in this averages function, sometimes there is no cell meeting the criteria in averages(), so this 'For next' loop stops when there is no cell meet those criteria.
What I need to do is that this function returns '0' or blank when no cell meets criteria.
I tried this command
Rich (BB code):
Rich (BB code):
Rich (BB code):
port_return.Columns(4).Cells(n).Value = WorksheetFunction.IfError(WorksheetFunction.AverageIfs(monthlydata.Columns(2), monthlydata.Columns(3), "=W", monthlydata.Columns(5), ">0.7"), "")
Can you guys please help me out?