Indirect within a formula

CBoukal

New Member
Joined
Oct 3, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
  3. Mobile
  4. Web
I read an old post on using indirect within a formula but it doesn't really work. I am trying to use the text of a cell within the formula below. B2 is a sheet name within the workbook. Rather than retyping the sheet name 60 times or using the search replace for Sheet, is there a way to make this work?
=COUNTIF(INDIRECT(B2)!$H$3:INDIRECT(B2)!$H$500, "Win")
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You have to write all of the range inside the INDIRECT():

Excel Formula:
=COUNTIF(INDIRECT(B2&"!$H$3:"&B2&"!$H$500"), "Win")
 
Upvote 0
You have to write all of the range inside the INDIRECT():

Excel Formula:
=COUNTIF(INDIRECT(B2&"!$H$3:"&B2&"!$H$500"), "Win")
Thank you for that, it makes sense now but I get #REF! error. It works fine when its typed out.
 
Upvote 0
This gives me #ref also. But If i take the indirect out it works fine.
=COUNTIF(INDIRECT("Ethan!$H$1:Ethan!$H$500"), "Loss")
 
Upvote 0
Thank you for that, it makes sense now but I get #REF! error. It works fine when its typed out.
That's what I get for trying to write it out outside of Excel.

Excel Formula:
=COUNTIF(INDIRECT(B2&"!$H$3:$H$500"), "Win")
 
Upvote 0
Solution
This gives me #ref also. But If i take the indirect out it works fine.
=COUNTIF(INDIRECT("Ethan!$H$1:Ethan!$H$500"), "Loss")
Because the sheet name only needs to be at the start of the reference, not in the middle too. That was my mistake why the first one gave you the error. See my fix above.
 
Upvote 0
Because the sheet name only needs to be at the start of the reference, not in the middle too. That was my mistake why the first one gave you the error. See my fix above.
You are awesome thank you very much!!!!
 
Upvote 0

Forum statistics

Threads
1,215,336
Messages
6,124,328
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top