Indirect reference to sheet names - excel

I have a several worksheets named Order 1, Order 2 etc. and a main sheet with the following table:
A B
1 Buying Price
2 Order 1 ='Order 1'!P2
3 Order 2 ='Order 2'!P2
ColumnA has the name of the relevant worksheet and ColumnB returns the value of P2 in that worksheet.
How do I modify the formula ='Order 1'!P2 so that the text is taken from the corresponding cell in ColumnA?
Tried a lot but every time I am getting incorrect formula error.

Try the INDIRECT formula:
=INDIRECT("'"&A2&"'"&"!$P$2")
A2 is the reference to the sheet name

Related

Extract only rows that are not in both sheets into a third sheet

I have 2 excel sheets with similar column values (legal_id). Is there a way to extract only rows that are not in both sheets into a third sheet? For example if social security number 111111 isn't in both sheets, then that persons row would be placed in the third sheet..please see images below.
Sheet 1
Sheet 2
Sheet3_DesiredResults
Before I get backlash about not attempting code this is what I tried,
I thought this formula would highlight true or false to values that are not in the same sheet, then I could just delete every field that returned true to be in both sheets , but it doesn't work. I'm not a programmer, I need help. Please don't tell me to take a VBA tutorial.Instead of making a third sheet , I made a helper column on the first sheet and used the formula:
=(ISNA(MATCH(A2,Sheet1!A:A,0)))=FALSE
Like anticipated in my comment, you might use 2 ranges in the third sheet and the COUNT.IF function. The formulas you need are these:
=IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A2)=0,Sheet1!A2,0)
.
=IF(COUNTIF(Sheet1!$A:$A,Sheet2!$A2)=0,Sheet2!A2,0)
Place them in 2 proper cell in the third sheet (let's say A2 and E2), drag them to cover the two lists. Empty cells or cells with IDs in both Sheet1 and Sheet2 will return 0. If you don't like 0 and you prefear "", you might use these:
=IF(IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A2)=0,Sheet1!A2,0)=0,"",IF(COUNTIF(Sheet2!$A:$A,Sheet1!$A2)=0,Sheet1!A2,0))
.
=IF(IF(COUNTIF(Sheet1!$A:$A,Sheet2!$A2)=0,Sheet2!A2,0)=0,"",IF(COUNTIF(Sheet1!$A:$A,Sheet2!$A2)=0,Sheet2!A2,0))
I have solved your query. Please have a look below.
First as expected, i created 2 sheets with same data as mentioned in image for simplicity.
Sheet 1 with Helper column
Sheet 2 with Helper column
Step 2 : I converted the sheet data into table for efficiency.
Step 3 : I used the COUNTIF function and IF function in Sheet 1 Helper column throughout.
=IF( COUNTIFS(Sheet2!Legal_id, [#[Legal_id]]) = 0, "N/A","" )
Similiarly we have to implement this formula in Sheet 2 Helper column.
=IF( COUNTIFS( Book1!Legal_id, [#[Legal_id]]) = 0, "N/A", "")
Explanation of above formula: The COUNTIF Function counts number of corresponding occurrences of Legal_id, in Sheet 2 Legal_id column. If count = 0 i.e means legal_id is not present in Sheet 2, so we use IF statement to assign 'N/A' value in Helper column else nothing ''.
Same explanation follows for sheet 2.
Now We Filter the Rows with N/A values to delete as mentioned by you in comments. or Insert it in third Sheet by copy paste.
The best way to accomplish your task is to use vba. But, if you want to use the ISNA(MATCH formula, you will need to wrap your formula in an IF statement and place the formula in each cell in Sheet3.
STEP 1: Paste the below formula in Cell A2
=IF(ISNA(MATCH(Sheet1!A2,Sheet2!A:A,0)),Sheet1!A2,"")
STEP 2: hold down CTRL+SHIFT+ENTER to enter it as an array formula
STEP 3: Hover over the dot in the right-bottom corner of the cell and drag down to the number of used rows you have in Sheet1 Note: the formula will change for each row
STEP 4: Then drag across to Column C Note: the formula will change for each column
The data from Sheet1 that is not in Sheet2 will now be in Sheet3, separated by blank rows, you can select the blank rows and delete them.

Getting sheet name dynamically with fixed indirect cell reference

I have created an Excel file named Sales consisting of the sheets: Settings, Country A, Country B.
In the sheet Settings I have the following values:
A B C
1
2 $B$1
3
4 Country A
5 Country B
6
In the cells A4 and A5 I have the following formulas:
A4 = MID(CELL("filename",'Country A'!$B$1),FIND("]",CELL("filename",'Country A'!$B$1))+1,255)
A5 = MID(CELL("filename",'Country B'!$B$1),FIND("]",CELL("filename",'Country B'!$B$1))+1,255)
As you can see I use the formula as a dynamic reference to get the name of the other sheets into the sheet Settings.
All this works fine so far.
However, now I want to achieve that the part $B$1 within in the formula is used as an Indirect reference to the Cell $A$2 within in the sheet Settings. At the same time I want that the sheet name remains dynamically.
Therefore, the desired result is that the sheet name is automatically adjusted if the user changes the name of the sheet but in case the user delets columns, rows or cells the reference always remains at $B$1.
What do I need to change in my formula to make this work?

Automatic population of an excel sheet

I am looking to make a form in which you can pull down a menu and have fields populate based on your selection. On my excel workbook I have Sheet 1 which is the menu and Sheet 2 which has the data.
Sheet 1 is laid out as such
Item Code Description Wholesale Price Retail Price
Sheet 2 is:
00001 Beans 0.45 0.67
I have setup a drop down list in A1 (Item Code) to reference the item code range on Sheet 2 but what I want to happen after I select the item code is for the rest of the information to populate. I have come close using VLOOKUP but I just don't seem to be able to nail it down.
Any suggestions?
In Sheet1:
B2 =VLOOKUP(A2,Sheet2!$A$1:$D$10,2,FALSE)
C2 =VLOOKUP(A2,Sheet2!$A$1:$D$10,3,FALSE)
D2 =VLOOKUP(A2,Sheet2!$A$1:$D$10,4,FALSE)
Where:
Sheet2!$A$1:$D$10 is your reference table in Sheet2
In Sheet1 I assume you have a header row (hence A2, B2, C2, D2)
Sheet 1:
Formula:
=VLOOKUP($A2,Sheet2!$A:$D,2,FALSE)
Where
A2 is the range of the Item Code
Sheet2!$A:$D is the 4 columns to look in for data
2, 3 and 4 are the columns (within the above 4) of your desired data.
FALSE requires it to be an exact match
Sheet 2:
Result in sheet 1:
Note: I've formatted the A columns as text to preserve the leading zeros, hence the little green triangles in the cell corners.

Excel - copy/past range of cells if cell matches another cell in another worksheet

I'm sure this is simple, but I can't figure it out and am not very familiar with macros...
I have a workbook that has 5 sheets.
Sheet 1 - Has all employee name (2 cells - first and last name) with a lot of info
Sheet 2 to 4 - Has the employees divided up across these three sheets.
What I want to do:
If the employee first,last name on Sheet 1 matches the first,last name on sheet 2,3 or 4 then copy cells f,g,h,i,j,k,l from that row in sheet 1 to corresponding sheet 2-4 where name is found.
I hope that makes sense.... Basically, transfer/copy employee row from main sheet to sheet 2, 3, or 4.
If sheet1 a2 and b2=sheet2 b15 and c15 then copy sheet 1 f2,g2,h2,i2,j2,k2,l2 to sheet2's n15,o15,p15,q15,r15,s15,t15.
I've tried: =INDEX(RN!All_Original!F,MATCH(C3:D3,All_Original!C:D,0))
Thanks!!
I think you're getting there with the Index/Match you showed. I don't know how your data is laid out, but I think you're just a few small keys.
I have "Sheet1", which is this:
And in "Sheet2", we have:
So, we want to fill in, automatically, the "Fun Fact" for whoeever the person is, in this case Kobe Bryant. You can use this formula:
=INDEX(Sheet1!$C$2:$D$5,MATCH($A2&$B2,Sheet1!$A$2:$A$5&Sheet1!$B$2:$B$5,0),MATCH(C$1,Sheet1!$C$1:$D$1,0))
(Enter as an array, with CTRL+SHIFT+ENTER)
If you change "Fun Fact" to "Favorite Food", it will update with "Italian". You can use this formula on your other sheets. Obviously, you will need to adjust the range(s) as necessary.
Edit: Note that the range sizes in the formula must be the same size, for it to work properly. My last row is always 5. So, always use that range.

Formula - find and copy from sheet 1 to sheet 2

In Excel, I have sheet 1 with column a (ID numbers) and column b (contract numbers), and sheet 2 with column a (ID numbers).
I need to find the ID numbers from sheet 2 in sheet 1, and copy the relevant contract numbers in sheet 2 (in a new column).
Can you please help with the formula?
Sounds like you could use the VLOOKUP formula for this. The VLOOKUP formula will look for a specified value in the left-most column of a table or range, and then returns a value from the same row of a column you specify.
For example, say you have the following on Sheet 1:
You would then use the VLOOKUP formula on Sheet 2 to find the ID in Sheet 1 and return the correlated Contract, like so:
You could use a "vertical lookup" function in your second sheet. Use something like the pseudocode below in the cell you want the information to appear in the second sheet .. where column 2 contains the information "looked up" in sheet one that you want.
=vlookup(-cell reference containing ID in second sheet-,-reference to all of sheet 1-,2,false)

Resources