Excel SUMIF variations - excel

I'm trying to make a SUMIF function like this one
=SUMIF(OUT!$G$22:$G$70;'2018'!$B4;OUT!$J$22:$J$70)
But i would like instead of giving the name of the sheet OUT, i want the excel to read de name of the sheet from an other cell like i show on the img.
I tried =SUMIF(CELL("contents";E2)!$G$22:$G$70;'2018'!$B4;CELL("contents";E2)!$J$22:$J$70)
but still not working. Anyone knows how to do it?
Excel image

You need INDIRECT:
=SUMIF(INDIRECT("'"&E2&"'!G22:G70");'2018'!$B4;INDIRECT("'"&E2&"'!J22:J70"))
Note that since the ranges are literal text strings, you don't need to make them absolute since they won't adjust if you copy/fill anyway.

Related

Excel INDIRECT Function Range not Valid

In a column, I´m storing ranges as plain Text.
I then want to use these ranges in a formula. As everything so far was in the same workbook I had no issue.
Now I want to get value from another workbook so I added just the path of the file just in front of my range.
It gives me something like that (stored in cell R38):
'C:\Users\me\Documents\C251\[C251output_powereditor.xlsx]C251!'G4:G38
Then I' m trying to use the following formula :
MATCH("Stlnr.";INDIRECT(R38);0)
But I got a ref error.
If I try the following :
MATCH("Stlnr.";[C251output_powereditor.xlsx]C251!G4:G38;0)
It does work.
I´m not sure what the issue is with my indirect function. And before you ask the other workbook is open. :)
Thanks in advance
I think your problem could be that when you enter
'C:\Users\me\Documents\C251[C251output_powereditor.xlsx]C251!'G4:G38
into a cell, Excel treats the first ' as the symbol of starting a text field, so it thinks the path is C:\Users\me\Documents\C251[C251output_powereditor.xlsx]C251!'G4:G38.
Solution: Add a single quote either in the formula or in the data cell:
''C:\Users\me\Documents\C251[C251output_powereditor.xlsx]C251!'G4:G38
or
MATCH("Stlnr.";INDIRECT("'"&R38);0)

Excel "INDIRECT" function with parameter from "CONCATENATE"

I am using an INDIRECT function to get value of a cell (B4) for many sheets in my workbook.
At the moment I have to hard code the name of the sheets like this
=INDIRECT("WCNEXP!$B$4")
Ideally I would like to find a way to compile the name "WCNEXP" with the help of the CONCATENATE formula, like this
=INDIRECT("CONCATENATE(B18,C18)!$B$4")
but it does not work for some reason.
Is there another way to get the name compiled from 2 cells and use the INDIRECT Formula ?
Photo of the workbook
Your code is almost good.
the quotes must be placed after the concatenate function, and with the use of "&" to join them.
=INDIRECT(CONCATENATE(B18,C18)&"!$B$4")

How to make a reference in a formula dynamic on cell value base

I want to make this formula dynamic by using the values in column C to complete the reference to the right file. That way I can just drag the formula down instead of altering the dates all the time. Some help would be very much appreciated.
Already tried the indirect function but this only seems to work on open workbooks.
=IFERROR(INDEX('G:\AGL''s & TC''s\Performance\2019\ASHIFT\Januari\
["&TEXT(C8,"ddmmyyyy")&".xlsm]PICKING'!$KD$5:$KD$200;MATCH($B$3;'G:\AGL''s &
TC''s\Performance\2019\ASHIFT\Januari\
["&TEXT(C8,"ddmmyyyy")&".xlsm]PICKING'!$A$5:$A$200;0));0)
Mapping is correct. When i use the actual filename the expected results are shown.
Unfortunately, you cannot use a formula to generate a filename for INDEX(), INDIRECT() etc. functions. Excel just doesn't support this.
Excel keeps register of references to external workbooks, and it needs static data for it, so formulas are no-go here.

Iterate between workbooks using INDIRECT

I want to create a summary file where I wish to import the data from cell D11 from some workbooks. For this I try to use INDIRECT to call the workbook O284, where O284 through O296 consists of strings like:
2015-01 (for O284), 2015-02 (for O285 etc)
and where O285 is the sheetname, which is consistent for each workbook hence the $$'s.
=INDIRECT("'C:\Path\["&O284&"]"&$O$285&"'!$D$11")
Running this however does not return a value, but merely a ####. I have all the workbooks opened. I suspect I conduct the INDIRECT snippet wrong, but I can't figure out how. Does anybody have a clue?
Regards,
Btw, is there a way to achieve the same thing as with INDIRECT that work with closed workbooks without using macros? Like a "paste value" or something which you can use in the same way as INDIRECT but that returns a digit, without the formula notation in the cell?
EDIT:
=INDIRECT(CONCATENATE("'C:\path\[";O282;"]";$O$283;"'!D11"))
works for getting the value "D11" from the workbook O282. When I drag this formula out, the next column will reference to workbook P282. However, it still get cell D11. I want it to get the E11 cell from this workbook, and work like this. Does anyone have any idea?
=INDIRECT(CONCATENATE("'C:\";[#Path];"\[";[#WorkbookName];"]";[#SheetName];"'!";ADDRESS(11;COLUMN() - 11)))
I think up code is something that can you want.
Showing #### is sometimes because of cell width.

Using indirect function in an IF statement with quotes

I'm making multiple IF statements that are going to have the same layout. Instead of writing the reference sheet name I'd like to reference a cell for the sheet name.
Also in the interests of laziness I'd like to drag the formula so it changes locations it is looking at on the referenced sheet.
At the moment it looks like this.
=IF(sheet1!O2="","",sheet1!O2)
Simple enough.
However I want to use indirect and I can't write it without getting an error.
Last attempt was
=IF((indirect($B$3))!O2="","",(indirect($B$3))!O2)
where Sheet1 is in the cell B3
Doesn't work.
Any help on the correct syntax would be very appreciated.
You need to concatenate $B$3 and "!O2" to generate "Sheet1!O2" as a string for INDIRECT to work, as below:
=IF(indirect($B$3&"!O2")="","",indirect($B$3&"!O2")

Resources