How to use the INDIRECT function in Excel

0 votes

I am using in Excel the following formula that works to get the value of a cell:

=INDEX(Sheet1!$1:$1048576,MATCH("Component 1",Sheet1!$A:$A,0)+MATCH("Component 2",Sheet2!$B:$B,0),2)

For a new application, the sheet and component names are dynamic, meaning that they are allowed to change and are not necessarily "Sheet1", "Sheet2", "Component 1" and "Component 2". Therefore I have tried to twist the above formula using the build-in INDIRECT function. I have tried two different ways to make it work:

1-

=INDEX(INDIRECT(A1&"!$1:$1048576"),INDIRECT("MATCH("&CHAR(34)&B1&CHAR(34)&","&A1&"!$A:$A,0)+MATCH("&CHAR(34)&B2&CHAR(34)&","&A2&"!$B:$B,0)"),2)

2-

=INDIRECT("INDEX("&A1&"!$1:$1048576,MATCH("&CHAR(34)&B1&CHAR(34)&","&A1&"!$A:$A,0)+MATCH("&CHAR(34)&B2&CHAR(34)&","&A2&"!$B:$B,0),2)")

Where cells A1 and A2 values are the sheets' names and cells B1 and B2 receive the components' names.

Both approaches give an error #Ref!. But I really cannot see what is wrong.

I would really appreciate any information for me to understand my mistakes and any suggestions to improve these formulas.

Sep 27, 2022 in Others by Kithuzzz
• 38,000 points
922 views

1 answer to this question.

0 votes

Try this:

=INDEX(INDIRECT($A$1&"!$1:$1048576"),MATCH($B$1,INDIRECT($A$1&"!$A:$A"),0)+MATCH($B$2,INDIRECT($A$2&"!$B:$B"),0),2)

I hope this helps you. 

answered Sep 29, 2022 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer

How to use goal seek function in Excel user function?

In the Microsoft Excel Object-Sheet1(Sheet1), we can ...READ MORE

answered Oct 28, 2022 in Others by narikkadan
• 63,600 points
789 views
0 votes
1 answer

How to use VLOOKUP function in MS Excel

Here is the formula for cell G2: ...READ MORE

answered Nov 13, 2022 in Others by narikkadan
• 63,600 points
536 views
0 votes
1 answer
0 votes
2 answers

How to use the flat button in Flutter?

FlatButton is really easy to use. Where ever ...READ MORE

answered Nov 9, 2020 in Others by Vijay
• 200 points

edited Nov 9, 2020 by MD 4,635 views
0 votes
1 answer

Dynamic chart range using INDIRECT: That function is not valid (despite range highlighted)

Similar to Sean's fantastic response, mine also ...READ MORE

answered Dec 27, 2022 in Others by narikkadan
• 63,600 points
958 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,260 views
0 votes
1 answer

ImportError: openpyxl is required for loading excel format files

Forget the PsychoPy complications for the time ...READ MORE

answered Oct 3, 2018 in Python by Priyaj
• 58,020 points
1,125 views
0 votes
1 answer

In Blue Prism how to split excel column data into TWO columns

This is how I am doing it. Dim ...READ MORE

answered Oct 15, 2018 in RPA by Priyaj
• 58,020 points
4,395 views
0 votes
1 answer

How do I use the Indirect Function in Excel VBA to incorporate the equations in a VBA Macro Function

Try this: Sub Test() Dim str As String: str ...READ MORE

answered Jan 19, 2023 in Others by narikkadan
• 63,600 points
1,060 views
0 votes
1 answer

How can I use a command button in excel to set the value of multiple cells in one click?

Try this: Private Scan As Integer Private Sub CommandButton1_Click() ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,600 points
798 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP