Hey everyone,

first a big thanks to this amazing community. I have been learning from you for years <3

I´m trying to get the average of a column without the zeros being recognized in VBA.
The code for the regular average is working just fine, but when I exchange the average formula with AverageIf, it does not work in VBA.

Solution with 0 recognized in VBA that works:

Sub MittelwertDmit0()
Range("D34").Formula = "=Average(D1:D33)"

End Sub



If I change the average formula with one of the following two, which is what I need, it does not work anymore. Even though in Excel both of them work just fine, just not in VBA:
1.=AverageIf(D2:D33;">0")

2. =Average(If(D2:D33<>0;D2:D33))


Can someone help?

Thanks already in advance