简体   繁体   English

如何在Excel中基于IF条件将公式应用于单元格

[英]How to apply formula to cell based on IF condition in Excel

I have an Excel spreadsheed like the one shown below 我有一个如下所示的Excel Spreadsheed

A             B
10.02.2007    10
10.03.2007    12

Column A is date and B is price of share A列是日期,B列是股票价格

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 . 现在,在另一个电子表格中,我需要创建一个名为Return的新列。在此列中,我需要放置公式= ln(B2/B1)但条件是该公式仅适用于A列中的日期,范围为StartDate < currentDate < EndDate

So I want to 所以我想

  1. apply my formula only to specific period say only to 2007 year 我的公式仅适用于特定时期,例如仅适用于2007年
  2. have new column placed in another spreadsheet starting from given location say A1 从给定位置开始将新列放置在另一个电子表格中,例如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 也许还有Excel:以及允许StartDate < currentDate < EndDate 函数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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