excel - searching in tables located in different sheet - excel-formula

I would like to use vlookup function to find value in table located in another sheet.
BUT I want to read sheet name from one cell.
I tried:
VLOOKUP(D8,INDIRECT($B$4&"!$A:$B",FALSE),2,FALSE)
(where B4 contains sheet name)
but it doesn't work.
How I should use it?

try:
=VLOOKUP(D8,INDIRECT("'" & $B$4 & "'!$A:$B"),2,FALSE)
it should also work with spaces in the sheet name

Related

R1C1 Formula Notation and External Workbook References

Problem: When creating a VBA script to dynamically insert formulas into a sheet's cells, I've chosen to use R1C1 notation for the cell references in the current sheet (because their locations aren't fixed between files used), and a fixed reference to a specific column in a separate workbook. This fails because Excel is adding unexpected parentheses around the column letters of the external workbook location.
EXAMPLE:
Range(FormulaCol & FormulaRow).FormulaR1C1 = "=IFERROR(MATCH(RC[-4],'[" & ExternalFileNameVariable & "]Sheetname'!B:B,0),"""")"
When the formula is output into my target sheet the script is working on, the formula comes out looking like this:
=IFERROR(MATCH(BG44,'[filename.xlsx]sheetname'!B:(B),0),"")
The B:(B) ultimately results in the formula failing. I cannot use a variable reference since the location of the columns in my working spreadsheet will vary, but the columns' location in the external worksheet will be fixed.
I have to do this for several formulas. The only alternatives I can think of to address this are to create dedicated variables for the columns in the working spreadsheet I'm referencing and using FIND methods to locate each column's header and saving its column location to a variable... but I swear, there's got to be a better way.

Use cell text to reference sheet name in formula

I am creating a summary page for daily production reports. All sheets are in one workbook. Daily sheets are named 17-Oct, 16-Oct, 15-Oct, etc with a Monthly Summary sheet. The summary sheet contains a table with the first column being dates in the same date format as the tabs. I want to use the date in the first column of the summary worksheet to reference the tab with the same name and pull data from it. I have been trying to figure out a way to use the Indirect function to do this but nothing I've tried works. I don't want to have to manually edit the formula in each row to reference the corresponding sheet. I've seen similar questions but the solutions are not working for me.
Dates are numbers in Excel shown as the format dictates and sheet names are strings.
You will need to format the number as text in the INDIRECT:
=INDIRECT("'" & TEXT(A1,"dd-mmm") & "'!A1")

List specific sheet names of excel spreadsheet

I have a somewhat working solution to retrieve all sheet names from a excel spreadsheet without using macro's or VBA. I did find several solutions but they all required the file to be saved as macro-enabled spreadsheet or external tools.
My solution is this so far:
My First sheet is called 'First' and my last sheet is called 'Last'. In between I have several sheets with random names. These sheets in between have in the A1 Cell the following formula:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)&"\"
The first sheet has in B1 the following formula:
="\" &CONCAT(First:Last!$A$1)
And in B2 to Bx the following formulas:
=IF(ISERROR(FIND(CHAR(1),SUBSTITUTE($B$1,"\",CHAR(1),ROW()))),"",MID($B$1,FIND(CHAR(1),SUBSTITUTE($B$1,"\",CHAR(1),ROW()-1))+1,FIND(CHAR(1),SUBSTITUTE($B$1,"\",CHAR(1),ROW()))-FIND(CHAR(1),SUBSTITUTE($B$1,"\",CHAR(1),ROW()-1))-1))
To explain this:
FIND(CHAR(1),SUBSTITUTE($B$1,"\",CHAR(1),ROW()-1))
gets the occurrence of the the string "\" in $B$2 relative to the row. In A2 this is the first occurrence.
LEN($B$1)-LEN(SUBSTITUTE($B$1,"\",""))
gets the amount of occurrences of "\" in $B$2
ISERROR(FIND(CHAR(1),SUBSTITUTE($B$1,"\",CHAR(1),ROW())))
makes the values empty so dynamic named range can be created from it. I use the sheet for dropdowns and charts
For end-users I hide the first and last tab so they don't accidentally break the sheet.
Somehow this all works, but maybe anyone has a better solution. It looks a bit overkill. Does anyone know of a better solution??
Thnx,
Jorden
This is only an alternative:
in A1 of each sheet enter:
=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)
In A2 of the first sheet enter:
=TEXTJOIN("*",TRUE,First:Last!A1)
In A3 of the first sheet enter:
=TRIM(MID(SUBSTITUTE(A$2,"*",REPT(" ",999)),ROWS($1:1)*999-998,999))
and copy down:
(I don't know is this is any simpler.)

Dynamic sheet name in Excel

I can reference a sheet name from another sheet
='Sheet1'!A1
How can I do thus with formula (not VBA or Python, sadly) to find out the name of the sheet dynamically (ie without knowing the name sheet)? Just to be clear I'm after the sheet names/ tab names at the bottom of the window, not the worksheet name
I've got number of spread sheets with a number of sheets (all named differently) and I was looking for a formula that will work with all. One size fits all , if you will.
Try this:
In the Name Manager create a Name using this formula:
=REPLACE(GET.WORKBOOK(1),1,FIND("]",GET.WORKBOOK(1)),"")
Then in your worksheet, use INDEX function to retrieve sheet names like this:
=INDEX(SheetList,1)
To List all sheets then select the target range and enter SheetList as array formula using Ctrl+Shift+Enter.
{=SheetList}

how to pull data from a sheet named as per value in the cell on a different sheet

I have a multiple sheets in a workbook for orders on a same format and it will keep adding. Sheet name will be order number.
I wants to create a Quotation sheet with a different format but same information from any order i want to print the quotation agaisnt.
i am looking for a code or formula help to pick the information from Order sheet as per number / name on the quotation sheet. i.e. every time i change the number in a specific cell it pulls information from respective order sheet only.
will greately appreciate your help
Thanks
Naman
I have assumed your sheet names are in A2:A4 (just 1, 2 and 3) of some 'other' sheet and the reference of the cell you wish to refer to is always D6 (the value in B1 in 'other`, which can be changed):
The formula is B2 of 'other' (copied down) is:
=INDIRECT(A2&"!"&B$1)
My comment to this question describes one way to make such links dynamic.

Resources