我可以使用Excel INDIRECT函数运行引用单元格中包含为文本的公式吗?

时间:2018-10-26 15:47:31

标签: excel excel-formula

我正在尝试创建一个动态表单,该表单将根据“年份中的第N个Dayday星期”(例如,“ 2018年1月的第3个星期一”)的格式返回日期。

这些是我的列表:

+-----+--------------+-----------+---------------+-------------------+-----------+-----------------+
| Row | (A) Instance | (B) Instance Value | (C) DayofWeek | (D) DayofWeek Value | (E) Month | (F) Month Value |
+-----+--------------+-----------+---------------+-------------------+-----------+-----------------+
|   1 | 1st          |         0 | Monday        |     1,0,6,5,4,3,2 | January   |               1 |
|   2 | 2nd          |         7 | Tuesday       |     2,1,0,6,5,4,3 | February  |               2 |
|   3 | 3rd          |        14 | Wednesday     |     3,2,1,0,6,5,4 | March     |               3 |
|   4 | 4th          |        21 | Thursday      |     4,3,2,1,0,6,5 | April     |               4 |
|   5 | Last         |           | Friday        |     5,4,3,2,1,0,6 | May       |               5 |
|   6 |              |           | Saturday      |     6,5,4,3,2,1,0 | June      |               6 |
|   7 |              |           | Sunday        |     0,6,5,4,3,2,1 | July      |               7 |
|   8 |              |           |               |                   | August    |               8 |
|   9 |              |           |               |                   | September |               9 |
|  10 |              |           |               |                   | October   |              10 |
|  11 |              |           |               |                   | November  |              11 |
|  12 |              |           |               |                   | December  |              12 |
+-----+--------------+-----------+---------------+-------------------+-----------+-----------------+

我使用查找公式来获取返回的任何响应的值

+---------+----------------------------------+-----------------------------------+----+--------------------------------+----+-------+
|         |             Instance             |             DayofWeek             | in |             Month              | of | Year  |
+---------+----------------------------------+-----------------------------------+----+--------------------------------+----+-------+
| Name    | 3rd                              | Monday                            |    | January                        |    | 2018  |
| Value   | 14                               | 1,0,6,5,4,3,2                     |    | 1                              |    |       |
| Formula | =VLOOKUP(Instance,B2:C5,2,FALSE) | =VLOOKUP(DayofWeek,D2:E8,2,FALSE) |    | =VLOOKUP(Month,F2:G13,2,FALSE) |    | =year |
+---------+----------------------------------+-----------------------------------+----+--------------------------------+----+-------+

现在我正在尝试将这些值连接到公式中

  

= CONCATENATE(“ = date(”,year,“,”,Month,“,1)+”,Instance,“ + choose(weekday(Date(”,year,“,”,Month,“,1 ),)),“ ,, DayofWeek,”)“)

将生成一个包含此文本的单元格,该单元格看起来像公式,但不会运行。

  

=日期(2018,1,1)+14+选择(工作日(日期(2018,1,1),)),1,0,6,5,4,3,2)

是否可以运行此公式并通过从另一个单元格间接调用它来返回值?

我尝试过的其他事情:

之所以这样做,是因为我尝试了所有其他可以想到的方法,将CHOOSE数组复制到一个间接公式中,并且每次都被挫败。

我可以让这部分工作:

=DATE(year,Month,1)+Instance

这将显示数组

=INDIRECT("DayofWeek")

=N22&Chooseday solves as 43115+choose(weekday(Date(2018,1,1),)),1,0,6,5,4,3,2)

=DATE(year,Month,1)+occurrence+CHOOSE(WEEKDAY(DATE(year,Month,1),1),INDIRECT("G19"))返回#VALUE!

1 个答案:

答案 0 :(得分:2)

您不需要所有这些。此公式将替换所有查找表:

=DATE(D1,MONTH(C1 & 1),1+A1*7) - WEEKDAY(DATE(D1,MONTH(C1 & 1),8-MATCH(B1,{"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"},0)))

enter image description here