Data count discrepancy - excel

I have two columns with different amount of values in them. Col A has 2789 values, col B has 201 values.
Using the function
=IF(ISERROR(MATCH(A2,$B$2:$B$2789,0)),"",A2)
in col C and dragging it down to C2789, I get the values that exist in both col A and col B. I select them, paste them into notepad or word (to get rid of the formulas), paste them back into Excel and remove all the blanks using Find & Select.
I repeat this for all the values that don't match in col B and col C using
=IF(ISERROR(MATCH(B2,$C$2:$C$140,0)),B2,"")
You would expect C and D together to have 201 data items, but I'm getting 207 in the status bar between those two.
Can anyone shed some light on this? All input is welcome.

Related

Split multiple comma seperated to unique rows in excel

i am new to vba, i have a requirement in one of the report i need to generate
for example
A B C D E
R1 1,2,3 A,B,C Q,W,E 1
Once I run a macro it should show like below:
R1 1 A Q 1
R1 2 B W 1
R1 3 C E 1
this is a just a sample data, my excel has A - AO columns and almost 10,000 records
Please advice
One way you could do this without external tools is to use the Split function, which retuns an array of strings.
You could split each column and then add rows based on the same index, if that is what you need, or add rows based on all possible combinations.

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- How do I Find and Replace using the values from adjacent columns

I'm a complete newbie to excel so apologies for my lack of knowledge!
I have a spreadsheet with 3 columnns.
Column 1 has cells with a range of values that can be repeated several times ie A B C A A D.
Column 2 has a list of the unique values in column 1 ie A B C D.
Column 3 contains the values that I would like to updated Column 1 with ie a b c d.
What I need to do is search Column 1 using Column 2 as an array of values when a match is found replace it with the adjacent value in column 3. Ie find all the A's in Column 1 and replace with a.
I did start writing a very long if statement if value = A replace with a etc but I have hundreds of unique values so I'm sure this isn't the most verbose way
Thanks in advance for your help
Consider the use of VLOOKUP
Result = Application.WorksheetFunction.Vlookup ( lookup_value, table_array, col_index_num, [range_lookup] )

Problems with implementing a two criteria vlookup substitute (sumproduct or index)

I have data on two tables, DATA and SpreadCodes. I need to write a formula that functions like a two-criteria vlookup. My tables look like this:
DATA table:
Col B ... Col I
01142 589
57834 007
Where Column S is where I'm trying to put the formula and where entries in Columns B & I are numbers stored as text.
SpreadCodes table:
Col A ... Col E ... Col G ... Col J
57834 007 15.50 15.50
45785 35893 10.00 10.00
Where entries in Columns A,E & G are numbers stored as text and where entries in Column J are stored as numbers.
I am trying to search the SpreadCodes table for the row where entries in DATA column B equal SpreadCodes Column A and where Data Column I equal SpreadCodes column E. Once a match is found, I need it to return the value in SpreadCodes column G OR Column J (They are the same, except G is stored as text, J is stored as number, so whichever makes this work).
I have tried several approaches to try to make this work. Nothing I tried below would return anything except an #NA value
I first tried creating a "helper" column where I concatenated the columns in both tables then just compared those values.
I then tried using two different index/match formulas (where one has concatenation included) :
=INDEX(SpreadCodes!G2:G202,MATCH(1,(SpreadCodes!A2:A202=B2)*(SpreadCodes!E2:E202=I2),0),7)
=INDEX(SpreadCodes!A1:K202,MATCH(Sheet2!B2&Sheet2!I2,SpreadCodes!A:A&SpreadCodes!E:E,0),7)
When that didn't work, I tried a sumproduct formula (being careful to specify SpreadCodes column J, since that one was a numerical value):
=SUMPRODUCT((SpreadCodes!A2:A202=Sheet2!C2)*(SpreadCodes!E2:E202=Sheet2!I2)*(SpreadCodes!J2:J202))
Since these codes often have leading zeros, I keep the columns in text so they don't get cut off, but even still, I'm not sure why these formulas aren't working. I've seen these work for other data. Any thoughts/ideas would be appreciated.
The sumproduct() works for me.
=SUMPRODUCT((SpreadCodes!A1:A100=Data!B1)*(SpreadCodes!E1:E100=Data!I1)*(SpreadCodes!J1:J100))
As per your data, This is how my data sheet looks like

How to count unique records in a column that have a value in another column

I have this issue: here is my table
ColA ColB
te Y
te Y
alo
te Y
te
bb Y
aa Y
I want to count how many records in ColA, which has value "Y" in Col B. and if two duplicate record in A that also have same Y then just count one. (in this case, te record we just count one time)
Many thanks
I am not sure is there is a simple formula to achieve what you want, though it may be possible with an array formula of some kind.
The simplest way in my view would be:
Select your data
Select Data > Filter > Advanced Filter
Check the Unique Records Only checkbox
Select a range you would like to copy the results to in Copy to
Now hit OK
Now use =COUNTIF with criteria =Y to get number of unique records that also have Y
Edit - Array Formula Solution
I did some googling and found a site that shows how to return unique rows using an array formula. See here.
We can use that to return all unique rows in your rows in columns A and B, including rows where column B is blank. (I assume your data is in cell A2:B8)
=SUM(IF(((MATCH(A2:A8&B2:B8,A2:A8&B2:B8,0)) >=(ROW(A2:A8)-(MIN(ROW(A2:A8))-1)))=TRUE,1,0))
Once we know the total number of unique rows, if we subtract from that number the cells in column B that are blank (i.e. not equal to Y) then this should give us the total number of unique rows that have a Y in column B. We can now update the above formula as follows:
=SUM(IF(((MATCH(A2:A8&B2:B8,A2:A8&B2:B8,0)) >=(ROW(A2:A8)-(MIN(ROW(A2:A8))-1)))=TRUE,1,0)) - COUNTIF(B2:B8,"<>Y")
Type this formula in C1 and then press CTRL + SHIFT + ENTER as this is an array formula.
I tested this and it seemed to work ok.

Resources