Averageif with 2 criterias VBA

marieimh

New Member
Joined
May 10, 2018
Messages
1
Hi,

So I have 2 columms, columm A that is in days and hours (2017-01-01 00:00, for example is my first data in the day in cell "A2") and columm B that represent Temperature on that given time.

I want to find the average temperature between 6am and 6pm and give the answer in a cell.

Dim i As Long
i = (Range("A2").Value)
Dim x As Single
Dim y As Single
x = (i + 0.25) 'x=6am
y = (i + 0.75) 'y=6pm
ActiveCell.Formula = "=AverageIf(B:B,A:A," > "&(i+0.25),A:A," < "&(i+0.75))"

It says Error 13. Can someone help me?
 

Some videos you may like

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Watch MrExcel Video

Forum statistics

Threads
1,099,368
Messages
5,468,213
Members
406,573
Latest member
nasirpm

This Week's Hot Topics

Top