简体   繁体   English

插入一个公式作为对另一个公式的单元格引用

[英]Inserting a formula as a cell reference to another formula

I am trying to build a formula which will combine OFFSET (because I want to retrieve every other row from one worksheet onto another) and Match()), because I want the function to find the first cell reference using a lookup value.我正在尝试构建一个公式,该公式将结合 OFFSET(因为我想将一个工作表中的所有其他行检索到另一个工作表上)和 Match()),因为我希望该函数使用查找值查找第一个单元格引用。 Independently, my index/match works, my Substitute(Address()) works (to retrieve the column#row# instead of the cell value) and my Offset works.独立地,我的索引/匹配工作,我的 Substitute(Address()) 工作(检索 column#row# 而不是单元格值)和我的 Offset 工作。 However, when I put the substitute(Address()) inside of my Offset function (as the cell reference), the formula stops working.但是,当我将替换 (Address()) 放入我的 Offset 函数(作为单元格引用)时,公式停止工作。

-Match Function (works, finds the column number) - 匹配函数(有效,查找列号)

MATCH(T2, 'Sheet1'!1:1, 0)

-Substitute (works, switches column alphanumeric for column number) - 替代(作品,切换列字母数字作为列号)

SUBSTITUTE(ADDRESS(1,MATCH(T2, 'Sheet1'!1:1, 0), 4), "1", "")

-Offset alone (works, retrieves every other row from sheet 1) - 单独偏移(有效,从工作表 1 中每隔一行检索一次)

OFFSET('Sheet1'!$O$2,(ROW(D3)*2)-6,0)

-Final formula (doesn't work) - 最终公式(不起作用)

OFFSET('Sheet1'!$SUBSTITUTE(ADDRESS(1,MATCH(T2, 'Sheet1'!1:1, 0), 4), "1", "")$2,(ROW(D3)*2)-6,0)

I feel like it must be a problem with inserting the other formulas as a cell reference for OFFSET, but I can't figure out how to fix it.我觉得插入其他公式作为 OFFSET 的单元格引用肯定是一个问题,但我不知道如何解决它。

您需要添加间接:

OFFSET(INDIRECT("'Sheet1'!$"&SUBSTITUTE(ADDRESS(1,MATCH(T2, 'Sheet1'!1:1, 0), 4), "1", "")&"$2"),(ROW(D3)*2)-6,0)

The problem is the way you try to build your address.问题在于您尝试构建地址的方式。 You can't just build a text that looks like an address.您不能只构建看起来像地址的文本。 I think that SUBSTITUTE function is unnecessary.我认为SUBSTITUTE功能是不必要的。 But you need INDIRECT .但是你需要INDIRECT It converts a text into a real address.它将文本转换为真实地址。 I believe this is what you need at the end:我相信这就是你最终需要的:

OFFSET(INDIRECT(ADDRESS(2,MATCH(T2, 'Sheet1'!1:1, 0), 4, 1, "Sheet1")),(ROW(D3)*2)-6,0)

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

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