Merging only one column on matching rows - excel

I have a spreadsheet where I have duplicate records(rows). Typically I have 2 rows per record and I need one. The rows are identical apart from one column. Is there a way to merge duplicate rows based on their ID in Column A but only merge column D
Column B for example as the same number, I don't want to merge this column as it will provide the wrong figure as column D has different words per row.
Data is currently.
Column A Column B Column C Column D Column E Column F
178924 £125 £895 Card 82 92
178924 £125 £895 Stamp 82 92
178927 £11 £85 Card 52 69
178927 £11 £85 Stamp 52 69
Perfect result would be
Column A Column B Column C Column D Column E Column F
178924 £125 £895 Card, Stamp 82 92
178927 £11 £85 Card, Stamp 52 69

You could do the following formula in Column G
=$D1 & ", " & VLOOKUP($A1, $A2:$D6, 4, FALSE)
Where your data is entered into A1.
This will return #N/A for unmatched records (you can use IFERROR to mask this with something else if you require) and a concatenation of Column D as in your expected output for matched records. You can filter the results to remove the unmatched to display your desired result.
This solution only works for the first instance of your ID (assuming only 2 instances of each ID in your question). If you want to delete unmatched rows you would have to use VBA.

Related

How do I split a row of text into different columns according to number of characters using a macro in Microsoft Excel?

I want to know if I can use a macro in Excel to separate data in a single column into different colums according to number of characters. For example, what I have is this in column A
A
AB
ABC
1A
564
8
What I need is this, in colums A, B and C
A AB ABC
8 1A 564
Thanks.
Use the following formula in a new column B next to Column A:
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=1,ROW($A$1:$A$6),99999),ROW()),1),"")
Array Formula press Ctrl+Shift+Enter at the same time
and drag it down, it will write the Values of B whose Length is 1, and when it gives empty it means no more Values with Length 1
Small will find the Cell which length is 1 (Row()=1, 1st cell which length=1, Row()=2, 2nd cell which length =1 ...)
If will return all the rows for the corresponding condition
Index will return the Cell
Iferror return empty "" if no more match
For the second column write 2 instead of 1 in LEN($A$1:$A$6)=2
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=2,ROW($A$1:$A$6),99999),ROW()),1),"")
For the third column write 3 in LEN($A$1:$A$6)=3
=IFERROR(INDEX($A$1:$A$6,SMALL(IF(LEN($A$1:$A$6)=3,ROW($A$1:$A$6),99999),ROW()),1),"")

Excel Index match with multiple criteria?

I have 2 worksheets, Home and Data.
Data:
Column A Column B Col C Col D Col E Col F
ABC2 121 - ABC2 121 ABC2 3456 12/12/2016 =WeekNum(E1) - SPAM
123420121601 - 2678 123420121601 1234 2678 18/12/2016 =WeekNum(E2)
628428121601 - 9862 628428121601 6284 9862 21/12/2016 =WeekNum(E3)
Column A contains random text and a PO number and item no, e.g. the PO of ABC123456781011 would be 123456781011 and the item number would be 2678.
I am extracting the PO number into column B.
In Column C i am getting the first four digits of the PO, this is the supplier number.
In column D i have my item number. This is also extracted from the cell in column A.
The date in column E is also extracted from the PO e.g.
123420121601 = a date of 201216 but converted as date.
Note cell A1 contains no PO and is considered a SPAM row. i do not want/need to use it in anyway so it must be disregarded.
Next
Home:
Column H Column I Col J Col L
1234 2678 18/12/2016 123420121601
6284 9862 51 628428121601
I am trying to use an index match in col D that will give the PO number from my data sheet where the supplier number, item number and date match.
However, on the home sheet in column J, on the last row - a user has input a week number rather than the actual date. I still want to be able to return a PO value if either the date matches exactly or if the week number for that date matches.
Here's what i have so far but the index match is not checking my criteria properly and i am getting an incorrect result. It gives me a result from the PO of the first row on sheet data.
=INDEX(Data!B:B,SUMPRODUCT(IF(YEAR(Home!$J10)<2016,(Data!F:F=Home!J10),(Data!E:E=Home!J10))*(Data!C:C=Home!H10)*(Data!D:D=Home!I10)*ROW(Data!B:B)))
Please can someone show me where i am going wrong?

Index Match with multiple criteria not working properly?

I have 2 worksheets in an excel workbook.
Data
Column A Column B (PO) Column C (Supplier No) Column D (Item No) Column E(date) Column F (week no)
123406121601 - 555 =LEFT(A1,12) =LEFT(A1,3) =RIGHT(A1,3) 06/12/2016 =WEEKNUM(A1,21)
I have about about 1000 rows of data like the above.
In column A, each cell contains jumbled information consisting of a PO number and item number.
The PO number is the first 12 digits in the cell in column A, and the first 4 digits contain the supplier number.
The PO also is made up of a date, i.e. 123406121601 = a date of 061016 and once formated = 06/12/2016.
My formula's give the results below:
Column A Column B Column C Column D Column E Column F
ABC123409121601 - 555 123409121601 123 555 06/12/2016 49
On the second sheet, Home, i have the following:
Column A Column b Column C Column D Column E
123 555 06/12/2016 {INDEX MATCH FORMULA}
I am wanting to lookup the po number on sheet 2 where the supplier number, item number and date match - using the formula below:
=IF(C1<>"",INDEX(Data!B:B,MATCH(1,(Home!A1=Data!C:C)*(Home!B1=Data!D:D)*(Home!C1=Data!E:E),0)),INDEX(Data!B:B,MATCH(1,(Home!A1=Data!C:C)*(Home!B1=Data!D:D)*(D1=Data!F:F),0)))
Within this formula I have surrounded 2 index match formula's inside an if statement. This means the user can check for a result/PO Number based on the supplier number and item number and a specific date or the week number that date falls within.
For some reason, this index match works fine if im using static values and keeping my rows of data relatively short. However, for some reason, either by using formulas on sheet 'data' or by having more rows of data - this causes me to get the following result
NA!
Please can someone show me where i am going wrong?

matching multiple values from separate sheets in excel

I have two sheets of data I need to match and transfer values with.
First two columns 1A & 1B
Column 1A contains all unique numbers (these are invoice numbers that we bill out to our customers)
Column 1B contains revenues when we receive payment for these jobs.
second two columns 2A & 2B
I have started to scan our check reports and transfer the data into a simple two column excel sheet (2A & 2B) Column A contains invoice numbers that are also contained in column 1A, column 2B contains the data I want to be transferred into column 1B for each corresponding match between columns 1A & 2A.
I have done some digging and cannot seem to find a simple solution to my problem.
VLOOKUP is the solution.The formula to do this would go into sheet 1, Col B , Row 2 (Assuming you have a headers in row 1).
=VLOOKUP(A2, sheet2!A:B,2,false)
The formula works like so
VLOOKUP(lookup_value,table_array,col_index_num,range_lookup)
-lookup_value = a cell you want to lookup
-table_array = a range of columns with the lookup column in col1
-index_num = the column you want to return as an int ( in this case column 2)
-range_lookup = should be false to ensure an EXACT match

Sum the values in Excel cells depending on changing criteria

In an Excel spread sheet I have three columns of data, the first column A is a unique identifier. Column B is a number and column C is either a tick or a space:
A B C
1 d-45 150 √
2 d-46 200
3 d-45 80
4 d-46 20 √
5 d-45 70 √
Now, I wish to sum the values in column B depending on a tick being present and also relative to the unique ID in column A. In this case rows 1 and 5. Identifying the tick I use
=IF(ISTEXT(C1),CONCATENATE(A1))
&
=IF(ISTEXT(C1),CONCATENATE(B1)).
This leaves me with two arrays of data:
D E
1 d-45 150
4 d-46 20
5 d-45 70
I now want to sum the values in column E depending on the ID in column D, in this case row 1 and 5. I can use a straight forward SUMIFS statement to specify d-45 as the criteria however this unique ID will always change. Is there a variation of SUMIFS I can use?
I also wish to put each new variation of ID number into a separate header with the summed totals underneath, that is:
A B
1 d-45 d-46
2 220 20
etc...
You can try this:
To get the distinct ID's write (in H1 then copy right):
This one is an array formula so you need Ctrl Shift Enter to enter the formula
=INDEX($A$1:$A$5;SMALL(IF(ROW($A$1:$A$5)-ROW($A$1)+1=MATCH($A$1:$A$5;$A$1:$A$5;0);ROW($A$1:$A$5)-ROW($A$1)+1;"");COLUMNS($A$1:A1)))
Now to get the sum (H2 and copy right)
=SUMPRODUCT(($A$1:$A$5=H1)*ISTEXT($C$1:$C$5)*$B$1:$B$5)
Data in the example is in A1:C5
Depending on your regional settings you may need to replace ";" field separator by ","
Try this,
SUMIFS
=SUMIFS(B1:B5,A1:A5,"=d-45",C1:C5,"<>")
where "<>" means that the cell is not empty...

Resources