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)
Related
I have a matrix grid in "MasterSheetGrid". I have separate sheets that divide this info into certain dimensions, making it easier to handle for the user.
In order to make the file dynamic, i am trying to use INDIRECT Function within a function, to locate which row of the MasterSheetGrid to look for the information before returning.
The formula works when i specify the row manually, but using INDIRECT i receive a REF error, even though nothing is deleted.
Manual Formula =INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),MasterSheetGrid!6:6,0))
Formula to locate the row
=(MATCH($C6,MasterSheetGrid!$C:$C,0))
Attempt to merge both using INDIRECT by referencing the cell where the above formula is stored, which results in REF
INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),(INDIRECT(J2:J2,0))))
Ideally i would like to not have to use a cell to store the lookup row formula in, but i thought if i could create a correct formula with the cell reference, i could repeat for the formula.
Does anyone know what i am doing wrong?
This is the view of the user. The formula would sit within column K
This is the MasterSheetGrid view
Instead of using INDIRECT which would cause recalculation at any change in the file, I recommend using INDEX instead. You refer to a fixed sheet name, therefore no need to use INDIRECT.
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),INDEX(MasterSheetGrid!$1:$50,J2,),0))
Would be the equivalent of what you tried.
Proper use of INDIRECT would be:
=INDEX(MasterSheetGrid!$5:$5,MATCH((XLOOKUP($J6,$5:$5,6:6)),INDIRECT("MasterSheetGrid!"&J2&":"&J2),0))
And it's good practice to take the following into account (thanks David Leal):
If the Sheet name you're referring to contains one or more spaces you need to wrap the name in ' like 'Sheet name'!
To refer a range using INDIRECT you can use the following syntax (as a string delimited, for example delimited by "):
=INDIRECT("J2:J10")
for a cell, this works:
=INDIRECT(J2)
but if you try the same for a range:
=INDIRECT(J2:J10) -> #REF!
you get #REF!
If you are going to refer a Sheet from your Worksheet, then you need in all cases to enter the input argument as string:
=INDIRECT("Sheet1!A1:A10")
=INDIRECT("Sheet1!A1")
=INDIRECT("'Sheet 1'!A2") -> When Sheet Name has spaces use (') delimiter
Notes: By the way you are invoking INDIRECT using the second input argument (a1) which is optional with the value 0. It is not required for getting a referring a range as I showed before.
I suspect this is the issue you are having
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.
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.
Alright, I am trying to figure out if the following is possible so that I can use it in later projects. I have been testing and working on this code in a sample workbook, which is why the file name is garbage. So don't judge me.
I have a VLOOKUP:
=VLOOKUP(A6,[dfhdfh.xlsx]Sheet1!$A:$B,2,FALSE)
This function currently works great. But I want to replace the static table_array value in the function to a cell reference, where I can enter a different file name at will.
Something along the lines of:
=VLOOKUP(A3,CONCATENATE("[",F2,"]","Sheet1!$A:$B"),2,FALSE)
Where F2 contains the file name and extension dfhdfh.xlsx
But whenever I try to execute my VLOOKUP with it's nested CONCATENATE function, I get a #VALUE! error. What gives?
Follow up from comments
If your workbook dfhdfh.xlsx is always open, you can use
=VLOOKUP(A3,INDIRECT("["&F2&"]Sheet1!$A:$B"),2,0).
But if your wb is closed, INDIRECT doesn't work. In that case you need VBA solution.
About your formula:
1) CONCATENATE(A1,A2) is the same as A1 & A2.
2) Actually concatenation works and result of CONCATENATE("[",F2,"]","Sheet1!$A:$B") would be "[dfhdfh.xlsx]Sheet1!$A:$B", but excel doesn't recognize this string as reference.
So you need to use Indirect for this purpose:
INDIRECT(CONCATENATE("[",F2,"]","Sheet1!$A:$B")) gives you correct reference.
Entire formula would be:
=VLOOKUP(A3,INDIRECT(CONCATENATE("[",F2,"]","Sheet1!$A:$B")),2,FALSE).
But, using first point, you can make this formula shorter:
=VLOOKUP(A3,INDIRECT("[" & F2 & "]Sheet1!$A:$B"),2,FALSE)
very new to this and only just managed the vlookup, anyway,
i have a workbook which contains two Sheets. On Sheet1 I have the following formula (=VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE)) which displays the ID number from Sheet2. This works correctly but how do I get to appear as a hyperlink so once clicked it goes to the specific cell it got from the vloopkup on Sheet2?
I have tried =HYPERLINK(VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE) but I get the error "Cannot get the specified file".
I would be grateful if anyone can point me in the right direction, thank you.
Ok... this looks crazy. This should work for you. I tested it on my machine and it works:
=HYPERLINK(MID(CELL("filename"),SEARCH("[",CELL("filename")), SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))+1) & ADDRESS(MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2"),VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE))
Let's break it up a little just to explain some of the parts:
MID(CELL("filename"),SEARCH("[",CELL("filename")), SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))+1)
Returns a string [currentFileName], which is the required format for a hyperlink within a workbook.
MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2")
Returns the row number of value of CZ54 in the first column of your VLookup range.
ADDRESS(MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2")
Returns the address of the row found, and the column(3, from your vlookup) in sheet2.
So combined:
MID(CELL("filename"),SEARCH("[",CELL("filename")), SEARCH("]",CELL("filename"))-SEARCH("[",CELL("filename"))+1) & ADDRESS(MATCH(CZ54,Sheet2!$A$1:$A$176),3,,,"sheet2")
Returns the actual address for the hyperlink, which is the first parameter of the HYPERLINK formula.
The second parameter is the Vlookup you provided, and voilà.
Edit: A warning if anyone tries to use this for a similar issue, if the lookup_array used in Match or Vlookup does not start with Row 1 or column 1 respectively, you will need to offset the values sent to ADDRESS with a +(starting row or column - 1). Example: Match(CZ54,$A$2:$A$176)+1 instead of MATCH(CZ54,Sheet2!$A$1:$A$176).
Here's a more compact version of Daniel's formula.
Using Hyperlink to link to another sheet in the same workbook, you can replace the reference to the workbook name with #.
Eg =HYPERLINK("#Sheet2!$C$10","Click Here")
So, applying this you get
=HYPERLINK("#"&ADDRESS(MATCH(E21,Sheet2!$A$1:$A$176),3,,,"sheet2"),VLOOKUP(E21,Sheet2!$A$1:$Y$176,3,FALSE))
HYPERLINK is looking for text so if you were to do something like
=HYPERLINK(left(VLOOKUP(CZ54,Sheet2!$A$1:$Y$176,3,FALSE),255))
it should return a usable hyperlink