Dynamic Sheet referencing

RSCexcel

New Member
Joined
Jul 26, 2004
Messages
28
I have this formula that sums a column if it matches “dog” on column A on a sheet named “1.”

=SUMIF('1'!$a:$a,”dog”,'1'!$b:$b)

Is there a way to automate changing that sheet to “2,” then "3," ... for the next cells?

i.e.
=SUMIF('2’!$a:$a,”dog”,'2'!$b:$b)
=SUMIF('3’!$a:$a,”dog”,'3'!$b:$b)

and so on…

Thanks.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Assuming your sheet reference is in cell A1, try

=SUMIF(INDIRECT("'"&A1&"'!$a:$a"),"dog",INDIRECT("'"&A1&"'!$b:$b"))

Regards,
 
Upvote 0
That worked great Barrie. Thanks.

BTW, can I use the "INDIRECT" function for a text string as well?

i.e. from the example I used, can I do something like this to place the sheet reference after the text "dog?"

=SUMIF(INDIRECT("'"&A1&"'!$a:$a"),"dog&INDIRECT("'"&A1&"'"),INDIRECT("'"&A1&"'!$b:$b"))

thanks...
 
Upvote 0
RSCexcel said:
That worked great Barrie. Thanks.

BTW, can I use the "INDIRECT" function for a text string as well?

i.e. from the example I used, can I do something like this to place the sheet reference after the text "dog?"

=SUMIF(INDIRECT("'"&A1&"'!$a:$a"),"dog&INDIRECT("'"&A1&"'"),INDIRECT("'"&A1&"'!$b:$b"))

thanks...

I'm not clear on what you need the sheet reference for. :unsure: Would you be searching for "dog1"? If that's the case, just use

=SUMIF(INDIRECT("'"&A1&"'!$a:$a"),"dog"&A1,INDIRECT("'"&A1&"'!$b:$b"))

Am I on the right track here?
 
Upvote 0
I actually want to append "1" after the text "dog" and before another text (ex. "cat").
Therefore, the search will be "dog 1 cat", then "dog 2 cat" etc...
Where "1" and "2" are the sheet/tab names.
Sorry for the confusion.
Thanks.
 
Upvote 0
RSCexcel said:
I actually want to append "1" after the text "dog" and before another text (ex. "cat").
Therefore, the search will be "dog 1 cat", then "dog 2 cat" etc...
Where "1" and "2" are the sheet/tab names.
Sorry for the confusion.
Thanks.

Okay, assuming you'll have a space between the three:

=SUMIF(INDIRECT("'"&A1&"'!$a:$a"),"dog "&A1&" cat",INDIRECT("'"&A1&"'!$b:$b"))

Now we're there, right? :wink:
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,693
Members
449,048
Latest member
81jamesacct

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