英文:
How pass dynamic value to a INDEX function in Excel?
问题
我想编写一个动态的Excel条件来基于单元格内容获取一些值。
我的Excel工作表包含3个标签:Home
、tab_1
和tab_2
。在home
标签中,我有一些文本内容用于选择sheet
和table
。
在tab_1
工作表中,我有名为Table_1
、Table_2
、Table_3
和Table_4
的表格。
现在我想根据文本值从表格中获取一些元素。
**示例:**如果标签名称为Tab_1
,表格名称为Table_1
,那么我将从Tab_1
工作表中的Table_1
数组中获取第2个索引值。
我的计划是使用Excel公式来实现动态操作。
因此,我尝试编写以下逻辑以获取第2个索引值。
INDEX(INDIRECT("' "&$B$2&" '!B1:F1"),2)
在这里,它将把$B2
作为Tab_1
。我将表格值传递为'B1:F1'
。
现在,我不知道如何获取主工作表(Home
标签)中的单元格$B3
与表格Table_1
匹配的数组(而不是B1:F1
)。
有什么建议或帮助吗?
英文:
I want to write a dynamic excel condition to fetch some values based on the cell Contents.
My excel sheet contain 3
tabs. Home
, tab_1
and tab_2
respectively. In the home
tab, I have some text contents for selecting sheet
and table
.
In the tab_1
sheet, i have tables named as Table_1
, Table_2
,Table_3
and Table_4
.
Now I want to get some elements from the table based on the text values.
Example: if the sheet name = Tab_1
and Table name = Table_1
then i will take the 2nd index
values from Table_1
array in Tab_1
sheet.
My plan is to do dynamically using excel formula.
So i have tried to write the below logic to get 2nd index values.
INDEX(INDIRECT("'"&$B$2& "'!B1:F1"),2)
here it will take $B2
as Tab_1 . I am passing table value as "B1:F1"
.
Now i don't know how to get the matching array (instead of B1:F1
) with the cell $B3
in the home sheet (Table_1).
Any suggestion or help ?
答案1
得分: 0
Finally after some research, I found the solution. We can use MATCH function to check the exact row name.
INDIRECT("'"&$B$2&"'!A1:F4)
This will search in the next tab (cell B2 text name ie: Tab_1
and table from A1
to F4
cells)
MATCH($B2,INDIRECT("'"&$B$2&"'!A1:F4),0)
This will search the exact name (from cell B3
text ie: Table_1
) from the tab
So All together you can write below function:
INDEX(INDIRECT("'"&$B$2&"'!A1:F4),MATCH($B3,INDIRECT("'"&$B$2&"'!A1:F4),0),2)
I hope this solution will help you someone who facing for this kind of problems.
英文:
Finally after some research, I found the solution. We can use MATCH function to check the exact row name.
INDIRECT("'"&$B$2&"'!A1:F4)
This will search in the next tab (cell B2 text name ie: Tab_1
and table from A1
to F4
cells)
MATCH($B2,INDIRECT("'"&$B$2&"'!A1:F4),0)
This will search the exact name (from cell B3
text ie: Table_1
) from the tab
So All together you can write below function:
INDEX(INDIRECT("'"&$B$2&"'!A1:F4),MATCH($B3,INDIRECT("'"&$B$2&"'!A1:F4),0),2)
I hope this solution will help you someone who facing for this kind of problems.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论