简体   繁体   中英

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). 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. 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. I also tried using the Address function, but it returned with quotation marks too. An example input for B2 in the formula is 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.

=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)))

Wrap your references in the INDIRECT function. From the documentation:

Use INDIRECT when you want to change the reference to a cell within a formula without changing the formula itself.

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

and

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

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