Hi everyone!

I am trying to automate an excel file for stock trading. What I have done so far is that I created a macro that let me select the name of the stock, the start date, the end date, the frequency of the data and fetches all the data from yahoo finance.

However, I would like to automate also the next steps, but I am struggling to find a solution.

In column H I have a formula to calculate the returns for the day and I would like this formula to automatically get updated when the macro fetches data for a new stock, which might have a different time span and therefore more (or less) rows of data.

I would really appreciate if someone has a solution for this!
Thank you!