|A couple of points....|
First, rarely do you have to Select a range to perform an action on it. It is more efficient if you don't Select the Range and it makes the code easier to follow.
Range("D25").FormulaR1C1 = "=COUNTA(R[-24]C[-3]:R[-10]C[-3])"
Second, I'm a little confused as to what you are trying to do.
As far as I can tell you are:
1 - Putting the COUNTA formula in D25
2 - Setting the variable NO_LINES equal to the result of that formula.
3 - Setting D25 equal to the value of NO_LINES, thus replacing the formula with the result of the formula.
If that's the case, why not just use the COUNTA function in VBA and put the final result directly in the cell?
Range("D25") = WorksheetFunction.CountA(Range("A1:A15"))
Instead of putting the formula in the cell, this will put the value (e.g. 11) in the cell.
You could then use that value in your HLOOKUP:
Range("your_range").FormulaR1C1 = "=HLOOKUP(""X"",R1C1:R20C19," & Range("D25") & ",0)"
If you are only using the COUNTA to determine the value for use with HLOOKUP and don't really need it in a cell, you can combine everything into one VBA line:
Range(your_range).FormulaR1C1 = "=HLOOKUP(""X"",R1C1:R20C19," & _
WorksheetFunction.CountA(Range("A1:A15")) & ",0)"
Finally, if that is all you are doing with the VBA, you can combine the HLOOKUP and COUNTA right in the Excel cell: