简体   繁体   English

根据单元格值设置范围

[英]Set Range based on Cell Value

In the Index and Match functions, the columns are fixed (column C for the index range and Column F for the Match range). 在索引和匹配函数中,列是固定的(索引范围的列C和匹配范围的列F)。 The starting row for both is on a seperate page "Input" Cell C7 and ending row for both is on the same "Input" page but Cell C10. 两者的起始行位于单独的页面上“输入”单元格C7和两者的结束行位于相同的“输入”页面上,但是单元格C10。 The ranges are on a sheet "Constants". 范围在“常量”表上。 The formula is on a sheet "Summary". 该公式位于“摘要”表上。 The starting and ending rows will change project to project and I need a way for these formulas to update based on the row values on the "Input" page. 开始和结束行将项目更改为项目,我需要一种方法,根据“输入”页面上的行值更新这些公式。

I think the issue is that the ranges as calculated are returned with quotation marks at the beginning and end. 我认为问题是计算的范围在开头和结尾都带有引号。 When I hard code the current ranges, the quotation marks aren't there. 当我硬编码当前范围时,引号不存在。 I tried the Substitute function to replace the quotations with nothing but they remained. 我尝试使用Substitute函数替换引号,但它们仍然存在。 I also tried using the Address function, but it returned with quotation marks too. 我也尝试使用Address函数,但它也返回引号。 An example input for B2 in the formula is P102. 公式中B2的示例输入是P102。 Input!C7 = 1271, Input!C10 = 1400. So the code is trying to return the value in Column C on the constants page by matching the row 102 is in in Column F. 输入!C7 = 1271,输入!C10 = 1400.因此代码试图通过匹配第102列中的行102来返回常量页面上的列C中的值。

=IF(OR(RIGHT(B3,2)="01",RIGHT(B3,2)="64"),"REFERENCE",INDEX("Constants!C"&Input!$C$7&":"&Input!$C$10,MATCH(NUMBERVALUE(RIGHT(Summary!B3,3)),"Constants!F"&Input!$C$7&":"&"F"&Input!$C$10,0))) = IF(OR(RIGHT(B3,2)= “01”,RIGHT(B3,2)= “64”), “参考”,INDEX( “常量!C” 和输入$ C $ 7! “:” &输入! $ C $ 10 MATCH(NUMBERVALUE(RIGHT(摘要B3,3)), “常量˚F!” &输入$ C $ 7! “:” 和 “F” 和输入$ C $ 10,0!)))

Wrap your references in the INDIRECT function. INDIRECT函数中包装您的引用。 From the documentation: 从文档:

Use INDIRECT when you want to change the reference to a cell within a formula without changing the formula itself. 如果要更改公式中单元格的引用而不更改公式本身,请使用INDIRECT

INDIRECT("Constants!C"&Input!$C$7&":C"&Input!$C$10)...

and

INDIRECT("Constants!F"&Input!$C$7&":F"&Input!$C$10)...

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

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