The column codes of your verbal description do not match the column codes of your screenshot. So just to be clear, in the following answer I will refer to the column codes as given in your screenshot.
The formula that you included does compute the result for me, by the way it is set up, it does not calculate what you described verbally.
In its form as written in your question, the formula ignores the company name and when faced with an 'NA' value, it returns the first number it finds starting from the top.
If I understand correctly, you want the formula to only take into consideration numbers associated with the same company name in column A, and when faced with 'NA', return the "most recent" number it finds for that company starting from the current row going up (given that date values are in order).
The following formula incorporates those features when pasted into cell D2:
=IFERROR(INDEX(FILTER($C$2:$C2,($A$2:$A2=$A2)*(ISNUMBER($C$2:$C2))),SUM(($A$2:$A2=$A2)*(ISNUMBER($C$2:$C2)))),"NA")
With this solution, the company names do not have to be in order, yet the date values do. The formula can be adjusted for cases where neither company names, nor date values are in order.
Note that the FILTER function is only available in Excel for Microsoft 365 and Excel 2021. In Excel 2019, Excel 2016 and earlier versions, it is not supported.