Originally Posted by
RickS650
I have now run the macro recorder on the weekday part and got the correct answer:
Sub Macro1()
' Macro1 Macro
Range("T2").Select
Selection.FormulaArray = "=SUM(IF(WEEKDAY(RC[-2]:R[381]C[-2])=4,1,0))"
Debug.Print Range("T2")
' Result is 71 - correct
End Sub
You rarely need to select
Range("T2").FormulaArray = "=SUM(IF(WEEKDAY(RC[-2]:R[381]C[-2])=4,1,0))"
Originally Posted by
RickS650
but I would like to put the result into a variable (say x) but, of course, I can't because it is an array. This is now personal between me and this macro..... I WILL win!
You can evaluate the formula
x = Application.Evaluate("=SUMPRODUCT(--(WEEKDAY(A2:A100)=2),B2:B100)")