How to duplicate and sync tables based on ID column in Excel? - excel

I'd like to duplicate a table in Excel onto a different worksheet, add columns to the new table, and keep the rows synced.
(p.s I'm not sure how to add images of the Excel sheet in here?)
For example, I have a table (Table1):
ID Data
A 1
B 2
C 3
D 4
I'd like to duplicate it in another sheet (Table2) and add a column that's only in the new table:
ID Data Data2
A 1 a
B 2 b
C 3 c
D 4 d
And I'd keep the rows synced, so that if I add, delete or amend a row in the original table (Table1), the new table (Table2) remains consistent including the added column that only exists in the new table.
For example, if I delete the row with ID "B" in the original table, I'd like this to happen in the new table:
ID Data Data2
A 1 a
C 3 c
D 4 d
I've been able to duplicate the table via a connection or query, but the added column in the new table doesn't stay in sync. For example, at the moment if I delete the row with ID "B" in the original table, this happens in the new table:
ID Data Data2
A 1 a
C 3 b
D 4 c
The columns that are in the original table update correctly, while the new column seems to be ignored.
I need to use Excel and if possible without VBA, but if VBA is the only way this will work then I'll need to use it.
I'm pretty desperate so any tips in the right direction would be gratefully received!!

Related

Excel - how to look in a dynamically changing range of multiple rows and columns and retrieve data

I have 2 excel files. 1 is a workfile in which I work, the other is the output of a database. See pic 1 for my database output (simplified).
What we see here:
The purchase order numer in column A
The row in the database in column B
The status of the row in the database in column C
The classification in column D, where W means a product we want to measure and P meaning delivery costs, administration costs etc (we don't want to measure this)
The number of items ordered and the number of items delivered in column E
The company name and product info in column F
Now, what I want, is something like this:
I want this table to be filled automatically based on the database output. It works for column B, but I'm stuck on column C, D and E.
What I want from you!
I need help with column C, D and E.
Number of rows: it needs to calculate the rows only with W in column D. So for item 4410027708 it has to be 2 (only 2 rows with W) and for item 4410027709 it should be 1.
Items ordered: it needs to add-up all the values that are directly to the right of the W in column D. So, for 4410027708, it needs to add up 3 and 5. It must ignore all the rows with P!
Items to be delivered: You may already guess this, but it needs to add up all the values in column E that are on the same row as column C with To be delivered, but only for the W rows (not the P versions). So, for item 4410027708 this should be
I suggest easy if ColumnA can be filled down first (including for the last entry) then assuming the database output sheet is called Sheet1, in:
C2: =COUNTIFS(Sheet1!A:A,A2,Sheet1!D:D,"W")
D2: =SUMIFS(Sheet1!E:E,Sheet1!A:A,A2,Sheet1!D:D,"W")
E2: =SUMIFS(Sheet1!E:E,Sheet1!A:A,A2,Sheet1!C:C,"To be delivered")
copied down to suit.

Excel Conditional Statement to determine which rows to delete and which to keep

I have 2 excel sheets containing data that will help me determine whether or not I need to delete or keep a row. Essentially, the way it works is that I have Column A in both sheets of the data which contains a code and column B of sheet 2 contains either a value of the text "Free". For each code in column A of sheet 1, I want to check if the same code exists in column A of sheet 2, and if so, I want to then look at column B of sheet 2 on that same row, and if it's cell contains "FREE" I would like to delete the entire row in containing that code from sheet 1.
Sheet 1: Sheet 2:
A B C A B C
1234 Data Data 1234 FREE Data
1235 Data Data 1456 Value Data
1547 Data Data 1547 Free Data
1483 Data Data 1247 Value Data
Then we Would get:
Sheet 1: Sheet 2:
A B C *Decision A B C
1234 Data Data Delete 1234 FREE Data
1235 Data Data Keep 1456 Value Data
1547 Data Data Delete 1547 Free Data
1483 Data Data Keep 1247 Value Data
This is what I have tried, but there is an error here I can't figure out. I am assuming I am doing something wrong with the syntax. HS is the name range of column A of sheet 2
=IF((VLOOKUP(A2,HS,1) = A2) and (Vlookup(A2, HS, 2) = "FREE"), "delete", "keep")
Try with below formula. It will work
=IF(ISNA(MATCH(A1,Sheet2!A:A,0))=FALSE,"Delete","Keep")
Proof of Work
EDIT #1
As per the request, please see the sheet 2 formula
=IF(ISNA(MATCH(A1,Sheet1!A:A,0))=FALSE,"Delete","Keep")
Your AND is in the wrong place. It should start the multiple conditions and each condition needs to be separated by a comma:
=IF(AND((VLOOKUP(A2,HS,1) = A2),(Vlookup(A2, HS, 2) = "FREE")), "delete", "keep")
Does this accomplish what you are looking for?
=IFERROR(IF(VLOOKUP(A3;Sheet2!$A$1:$C$5;2;FALSE)="Free";"delete";"keep");"keep")

excel only show rows with difference values

Hi oh you all wise people.
Not sure if it is doable.. But here goes.
I have a "master" sheet with a set field set (it is the same fieldset I extract every time)
Sheet1:
A B C
-----------
1 B 2 BA
2 C 5 AB
Sheet3:
A B C
-----------
1 B 1 BA
2 C 5 AB
Since B:2 has been changed from 2 to 1, it should result in:
Sheet2:
A B C
-----------
1 B 2 BA
I would like to get the changes between my "master" sheet and the "next extraction" of data.
The challenge (I think) is that I only want the rows with changes displayed in a third sheet.
Sheet1 : Master Data
Sheet2 : Diff Reporting
Sheet3 : Weekly Extraction
Anyone?
Following dot.Py's suggestion, I would:
Copy both row sets to a new sheet
Add a column showing which sheet each row originally came from, let's call it "Source".
Use the 'Remove Duplicates' feature in the Data tab, but do not use the "Source" column as a duplicate criteria. (http://www.excel-easy.com/examples/remove-duplicates.html)
After removing duplicates you'll have both the old and new row for rows that have changed.
Filter based on the "Source" column and then delete any rows from the old sheet.

Grouping rows in table in Excel

I have the following table:
First Name Second Name Phone
A B 1
A B 2
C D 3
C D 4
I would like to get the required table (Every values in columns A and B that repeats will appear only in the first line of occurrence):
First Name Second Name Phone
A B 1
2
C D 3
4
You can accomplish this by using Pivot Tables.
Out of my head, you have to structure it like this:
Rows
First Name
Second Name
Phone
And it will show it the way you want it. You can change the show/hide for (sub)totals to change the result a bit.
If you want the First name and Second name on the same row, you will have to edit the Pivot Table to use Classic display.

Two Tables Excel values

I have two tables in two different sheets. In Table 1 and table 2 column 1 is for id's. but in Table 2 I have more id's than table 1.
What I want is: if a cell in table 2 column 2 is filled to check the id and if its in table 2 to mark "yes" in column 2 in Table 1.
This is the code I have been using but it stops when the ids don't match:
=IF(AND(Table 2[column 2]>0,VLOOKUP([column 1],Table 2[column 1],1,FALSE)=sheet 2!A5),"yes","")
You could put something like this in table 1 column 2. Assuming table 1 is in columns A,B and Table 2 is in columns D,E. That is column D is the id in table 2 and column E is the value in table 2.
This will return an error if there is an id in table 1 that isn't in table 2. To deal with this you could wrap it with iferror.
=IF(INDEX($E:$E,MATCH(A1,$D:$D,0))>0,"yes","")
Gordon
You might try:
=IFERROR(IF(VLOOKUP(Table1[[#This Row],[column 1]],Table2[#All],2,0)<>"","yes",""),"")
at the top of column 2 of Table1, adding spaces in the table names if you have been able to.

Resources