简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM