Home » excel » How to apply formula to cell based on IF condition in Excel

How to apply formula to cell based on IF condition in Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have an Excel spreadsheed like the one shown below

A             B
10.02.2007    10
10.03.2007    12

Column A is date and B is price of share

Now my task is calculate financial return of share using formula

return = ln(price_today / price_yesterday)

Now in another sreadsheet I need to create a new column called Return
In this column i need to place formula like = ln(B2/B1)
but on condition that this formula is only applied date in column A is in range
StartDate < currentDate < EndDate.

So I want to

  1. apply my formula only to specific period say only to 2007 year
  2. have new column placed in another spreadsheet starting from given location say A1

Please suggest

How to&Answers:

To reference a cell in another workbook you need to use something like

[Book1.xlsx]Sheet1!$A$1

To find the year number you need to ensure that the column is a valid Date column, and use something like

=IF(YEAR([Book1.xlsx]Sheet1!$A$1) = 2007,LN([Book1.xlsx]Sheet1!$B$2/[Book1.xlsx]Sheet1!$B$1), 0)

And also maybe Excel: And Function to allow for the StartDate < currentDate < EndDate