Removing effects from related time series on output time series

Hi all. I’m not an expert in stats so hopefully this is explained clearly

I have two time series, “output” timeseries and “factor A” timeseries. These are correlated with an r-squared of 0.4.

I want to create a new timeseries which removes the impact of “factor A” on “output”

Can I do this? And can I do this in excel?