There are multiple ways to do it.
1) Use a VBA macro to set the formula : Initially select the basic range (may be the first row by default) for the excel sheet and in the worksheet_change event, check the filledup cells and keep extending the formula to the next cell or rows. This will have performance impact. But could be effective.
2) Convert the sheet range (rows and columns) to a table : If you have the rows and columns defined, select the range and convert it to table (Insert menu table and select the range). Once you have the formula added to the table, the subsequent rows will have the same formula copied .
*please don't forget to ***upvote* and Accept as answer if the reply is helpful***