Formula to detect duplicate data in Excel (with a difficult variable!) - excel

I need to sanitise a mailing list, and am wondering if anyone knows of a formula to find out the following:
I have an excel spreadsheet with two columns A and B, the formula I need to do is: if [value in column B is duplicated] has [blank in column A] AND [data in column A] then show the value of Column B in a new Column C.
Example of data:
COL A | COL B
11/11/12 | **name#example.com**
03/09/11 | different#example.com
| **name#example.com**
06/01/12 | anothername#example.com
The formula would detect name#example.com is duplicated & it has a date in column A & further on has no value in column A, and therefore displays: name#example.com in Column C.
Hope that makes sense!

This should work (obviously changing the ranges to cover all rows):
=IF(AND(COUNTIF($B$2:$B$5,B2)>1,A2=""),B2,"")

Related

Conditional subtraction from multiple cells

A |B |C |....|K |L |M |
Tom |0 | |....|Tom |Jim |Dave |
Jim |1000 | |....|15000|14000|12000|
Dave |3000 | |....| | | |
Using Google Sheets for this one. I would like the values in columns K, L, and M to read from column B, detect if the corresponding cell from A reads one of 'Tom', 'Jim', or 'Dave' for example, and then subtract the amount from the correct column to reduce a running total. I've had some trouble figuring it out and tried to use conditional formatting to solve it but can't seem to quite get there. Is there a formula I can use that will read column B and subtract the amount shown from the correct column based on the name in column A?
So to pseudo-code it:
read(column B cell);
if(column B cell - 1 column = "Tom")
{
column K - (value of column B cell)
}
else if(column B cell - 1 column = "Jim")
{
column L - (value of column B cell)
}
etc.
Is there a simple method I can use to generate this result? Also thought about changing the formatting of a cell based on the name in the cell next to it and subtracting the value of any cell with that colour but this becomes unwieldy if names are added. Any assistance would be greatly appreciated!
would there be a way to constrain the formula to a single cell so I can have the total in a single location rather than down the columns? My plan is to have the total boxes scroll with the sheet and always be visible.
Let's assume that Columns A and B continue on down the sheet, with further name + amount entries. You want to have a single row of balances for each of the people.
The balance is then some initial value less the sum of amounts for that person. Say the amounts you've shown in row 2 are the initial values; here's how you could have row 3 reflect the remaining balance for each person (This is for "Tom", copy for the others):
=K2-sumif($A$2:$B,"="&K$1,$B$2:$B)
Alternative solution
This doesn't do exactly what you want, but it is more appropriate for a running total scenario, so others may find it useful to adapt to ledgers, etc.
The IF() function can be used to decide whether or not a value in Column B applies to one of the "total" columns, K to M.
Use this formula in K3, copy to the rest of the range:
=K2-if($A2=K$1,$B2,0)
This example is in Google Sheets, but the same formula works in Excel and other "compatible" offerings.
What you do is put the formula in each column.
Column K subtracts value of column B if column A = "Tom"
Column L subtracts value of column B if column A = "Jim"
etc

Search for specific number in column and fill cells from its adjacent cells

I have a list of employee ID's for each period of the year. Each ID has Specific stats for that time period. The problem I'm running into is the list order changes every period according to the employees tasks.
Cell 1A contains the Employees ID#(ID's are Numbers only if that makes a difference). Column B has the whole list of employee ID#. I need to figure out how to write a formula or vba that checks column B for the ID# that matches 1A and populate 1C-1J with the adjacent data found in column B (columns C-J).
I hope I explained myself correctly without being to confusing. I appreciate any help.
The vlookup formula looks at the first column of $B:$J (column B) and searches for $A$1 and if it finds it returns the value in the 2.(3.,4.,...,9.) column of $B:$J
A1 | B1 | =VLOOKUP($A$1,$B:$J,2,FALSE) | =VLOOKUP($A$1,$B:$J,3,FALSE) | =VLOOKUP($A$1,$B:$J,4,FALSE) | ... | =VLOOKUP($A$1,$B:$J,9,FALSE)

Column A numbers matched with Column B numbers that are assigned to Column C =column D?

This is my example
Column A are numbers
Column B are numbers
Column C are Names
The A column are numbers associated with a item sold to one place. Column B is the items sold and C is the person who sold them. I would like column D to show the item sold to this one place and who sold it. Let me know if that makes sense.
PS: Column A has 1304 rows. Column B and C have 6154 rows
It is hard to guess what your data looks like, so assuming your data looks as below:
Here is my solution, I think it is a simple VLOOKUP problem:
Paste this =IF(ISERROR(VLOOKUP(C2,$A$2:$A$4,1,FALSE)),"","SoldToPlaceA") to E2 and drag it down to copy.

Add cell string to another cell if 2 cells are the same for 2 rows

I'm trying to make a macro that will go through a spreadsheet, and based on the first and last name being the same for 2 rows, add the contents of an ethnicity column to the first row.
eg.
FirstN|LastN |Ethnicity |ID |
Sally |Smith |Caucasian |55555 |
Sally |Smith |Native American | |
Sally |Smith |Black/African American | |
(after the macro runs)
Sally |Smith |Caucasian/Native American/Black/African American|55555 |
Any suggestions on how to do this? I read several different methods for VBA but have gotten confused as to what way would work to create this macro.
EDIT
There may be more than 2 rows that need to be combined, and the lower row(s) need to be deleted or removed some how.
If you can use a formula, then you can do those:
Couple of assumptions I'm making:
Sally is in cell A2 (there are headers in row 1).
No person has more than 2 ethnicities.
Now, for the steps:
Put a filter and sort by name and surname. This provides for any person having their names separated. (i.e. if there is a 'Sally Smith' at the top, there are no more 'Sally Smith' somewhere down in the sheet after different people).
In column D, put the formula =if(and(A2=A3,B2=B3),C2&"/"&C3,"")
Extend the filter to column D and filter out all the blanks.
That is does is it sees whether the names cells A2 and A3 are equal (names are the same), and whether the cells B2 and B3 are equal (surnames are the same).
If both are true, it's the same person, so we concatenate (using & is another way to concatenate besides using concatenate()) the two ethnicities.
Otherwise, if either the name, or username, or both are different, leave as blank.
To delete the redundant rows altogether, copy/paste values on column D, filter on the blank cells in column D and delete. Sort afterwards.
EDIT: As per edit of question:
The new steps:
Put a filter and sort by name and surname. (already explained above)
In column E, put the formula =IF(AND(A1=A2,B1=B2),E1&"/"&C2,C2) (I changed the formula to adapt to the new method)
In column F, put the formula =if(and(A1=A2,B1=B2),F1+1,1)
In column G, put the formula =if(F3<F2,1,0)
In column H, put the formula =if(and(D2="",A1=A2,B1=B2),H1,D2) (this takes the ID wherever it goes).
Put the formulae as from row 2. What step 3 does is putting an incremental number for the people with same name.
What step 4 does is checking for when the column F goes back to 1. This will identify your 'final rows to be kept'.
Here's my output from those formulae:
The green rows are what you keep (notice that there is 1 in column G that allows you to quickly spot them), and the columns A, B, C, E and H are the columns you keep in the final sheet. Don't forget to copy/paste values once you are done with the formulae and before deleting rows!
If first Sally is in A1 then =IF(AND(A1=A2,B1=B2),C1&"/"&C2,"")copied down as appropriate might suit. Assumes where not the same a blank ("") is preferred to repetition of the C value.

Performing a find within a find EXCEL VBA

Please help me,
Take for example I have the following set of data:
Column A (Sheet1) | Column B (Sheet1) | Col. A (Sheet4) | Col B (Sheet4) | Col C(Sheet4)
----------1A2B----|---------1111------|-------1111------|--------AAAA----|------ABAB----|
----------2B1A----|---------2222------|-------2222------|--------BBBB----|------AABB----|
----------1B1B----|---------3333------|-------3333------|--------CCCC----|------AABB----|
I already have developed a function code that will find the corresponding value of Column B in sheet 1 to the column A in sheet 4. For example my code will automatically return the values AAAA & ABAB if for all 1111 values in Col B on Sheet 1.
The problem is that if the value in Col C Sheet 4 equals to AABB, i have to perform another search within another table (for example the table is located at sheet 5). And this time the basis of my seach will be the Col A on sheet 1 because Col A has its own mapping. So i have to perform another search. Can someone please help me with this. I am a newbie when it comes to excel vba. Oh and by the way it has to be on excel vba.
So for example if my code sees the value 2222 on sheet 1 Col B. It will be like this:
Column A (Sheet1) | Column B (Sheet1) | Col. A (Sheet4) | Col B (Sheet4) | Col C(Sheet4)
--------------1A2B----|---------2222----------|-------2222--------|--------BBBB-----|------AABB----|
The code will see the AABB and it will perform another search using the 1A2B code. The 1A2B is mapped to another table.
Please help me.
Sounds like you should use the VLOOKUP worksheet function at both levels. You can use the function in VBA with the following:
Application.WorksheetFunction.VLOOKUP(value to lookup, range to look in, column # to return data from, FALSE)

Resources