Getting an error message when i enter this formula - Not sure why

Maune

New Member
Joined
Aug 7, 2012
Messages
19
Good day all!

I am trying to enter a formula in a workbook that pulls it's data from other multiple workbooks. When I hit 'Enter' I am getting a pop-up box telling me the formula has an error.

This is the formula:

=SUMIF(INDIRECT(VLOOKUP($B$1,WBLINKS,2,FALSE))&"$J$3:$J$2500","=R",INDIRECT(VLOOKUP($B$1,WBLINKS,2,FALSE))&"$G$3:$G$2500")

where B1 is a dropdown box with a list of years.

WBLINKS is a named range that looks like this:

[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD="align: center"]S5[/TD]
[TD="align: center"]T5[/TD]
[/TR]
[TR]
[TD="align: center"]2015[/TD]
[TD]
[TABLE="width: 215"]
<tbody>[TR]
[TD][CBG DAILY COUNTS.xlsx]2015'[/TD]
[/TR]
</tbody>[/TABLE]


[/TD]
[/TR]
[TR]
[TD="align: center"]2016[/TD]
[TD][TABLE="width: 215"]
<tbody>[TR]
[TD="align: center"][CBG DAILY COUNTS.xlsx]2016'[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD="align: center"]2017[/TD]
[TD][TABLE="width: 215"]
<tbody>[TR]
[TD="align: center"][CBG DAILY COUNTS.xlsx]2017'[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]


In CBG's workbook the sheets are named 2015,2016,2017, etc.


Originally, this formula was set up for sheet 2015 and looked like this:

=SUMIF('[CBG DAILY COUNTS.xlsx]2015'!$J$3:$J$2500,"=R",'[CBG DAILY COUNTS.xlsx]2015'!$G$3:$G$2500)

It worked fine. Now, I want to allow the user to select any year to look at data and so I tried to modify the formula to look at different sheets in their workbook.

I have a feeling this is a simple fix, but I can't find an answer!


Thank you for any help :)
 
I just realized I left off the " ' " in front of the strings in column T. I do have them in my worksheet though! :)
 
Upvote 0
You also left out the ! that goes between sheetname and range
And you misplaced the ) of the indirect.

try
=SUMIF(INDIRECT("'"&VLOOKUP($B$1,WBLINKS,2,FALSE)&"'!$J$3:$J$2500"),"=R",INDIRECT("'"&VLOOKUP($B$1,WBLINKS,2,FALSE)&"'!$G$3:$G$2500"))
 
Upvote 0
Compare your new formula to your original one, there are some characters missing and a couple of missing parenthesis.

=SUMIF('[CBG DAILY COUNTS.xlsx]2015'!$J$3:$J$2500,"=R",'[CBG DAILY COUNTS.xlsx]2015'!$G$3:$G$2500)

So the revised formula should be

=SUMIF(INDIRECT("'"&VLOOKUP($B$1,WBLINKS,2,FALSE))&"!$J$3:$J$2500"),"=R",INDIRECT("'"&VLOOKUP($B$1,WBLINKS,2,FALSE))&"!$G$3:$G$2500"))

Is there any reason why you need to use vlookup? Based on your data layout you could simply use

=SUMIF(INDIRECT("'[CBG DAILY COUNTS.xlsx]"&$B$1&"'!$J$3:$J$2500"),"R",INDIRECT("'[CBG DAILY COUNTS.xlsx]"&$B$1&"'!$G$3:$G$2500"))
 
Upvote 0
Is there any reason why you need to use vlookup? Based on your data layout you could simply use

=SUMIF(INDIRECT("'[CBG DAILY COUNTS.xlsx]"&$B$1&"'!$J$3:$J$2500"),"R",INDIRECT("'[CBG DAILY COUNTS.xlsx]"&$B$1&"'!$G$3:$G$2500"))
+1
Good adjustment..
 
Upvote 0
The reason I used Vlookup is because I'm not smart enough to figure another way to do it! LOL!

In the back of my mind, I kept telling myself, there must be a simpler way, but I couldn't see it.

This is why i love this board, thank you all so much for your help!
 
Upvote 0

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