You are using a Visual Basic macro to place formulas into cells in a worksheet.
The formulas you put into cells must use the worksheet syntax.
The code I gave you:
dtEndDate = DateSerial(Year(Now), 12, 31)
is Visual Basic syntax.
In a worksheet cell you would use standard worksheet syntax:
Also in both examples you have an extra space:
" <= " instead of "<= "
The reason you get FALSE is that Visual Basic is evaluating this line:
"=(COUNTIF(H2:A200," <= " & DATE(2010,12,31))*100)/COUNT(H2:A200)"
Because of the double quotes, it is comparing this text:
(using <=) with this text:
" & DATE(2010,12,31))*100)/COUNT(H2:A200)"
Visual Basic treated the double quotes in your formula as the start and end of pieces of text.
The <= fell between quoted text and was treated as an operator.
As the the first piece of text was not equal to or less than the second piece of text, the comparison returned FALSE,
which is what was placed in the cell.
To do this you have to create the formula without using any characters that Visual Basic would interpret as operators or 'control codes' so " and & are not allowed and have to be replaced by their equivalent character codes:
Range("M9").Formula = "=(COUNTIF(H2:A200," & Chr(34) & "<=" & Chr(34) & Chr(38) & "DATE(2010,12,31))*100)/COUNT(H2:A200)"
Note that you do not have to select a cell to act on it.
Also you are mixing .Formula and .FormulaR1C1
In your second example you are telling Excel to expect a formula that uses the R1C1 notation, but you are passing it an A1 notation formula. Excel tries to change H2:A200 into an R1C1 notation and I think that it assumes that H2 is a worksheet name (not sure on this - but you certainly don't get the result you expected).
... and just an observation: I am wondering why you are using Visual Basic code to write formulas.
If your code did some calculation to create the formulas that would make sense, but here all the formulas are already hard-coded, so it's no different to entering the formulas directly into the cells themselves.
What you have seems to be complicated.