VLOOKUP on first and last name with no unique ID - vba

Situation:
I have two sheets: The first sheet contains a list of employee names; the second sheet contains a piece of a pay report for employees. I need to pull the employee pay data from sheet 2 to sheet 1 by searching for the employee on sheet 2. What complicates this is the report on sheet 2 contains changing employees, pay, and has no unique ID.
I am looking to fill in column A. I cannot permanently modify this sheet as it affects downstream reporting.
I split column B which was previously first name, middle initial (if any), last name. Note, about 10% of the names may have a different last name. For example, sheet 1contains the name Tara Feather, but the second report uses her maiden name of Tara Bird.
Attempts so far:
I am new to Excel, and am just learning VLOOKUP. My first attempt was to pull the data based on the last name column on sheets 1 and 2, and enter data. Unfortunately, while that worked for 90% of the entries, the last 10% had the wrong values and the audit to correct took more time than manual entry.
Possible Ideas:
My next thought was to combine an If statement and VLOOKUP so that if last name matched, and first name matched, then execute the VLOOKUP and pull values, or enter "ERROR".
With this new thought, I don't know if I'm now in macro territory or if there are a combination of functions that can help. Ideally, the more it can do with 100% accuracy the better. However, if it can highlight the names it completed on sheet 2, I can always enter the non-highlighted manually, still saving time.
What are your thoughts and direction?

You want 100% accuracy, but if someone has different names on the two sheets, then that's never going to work.
So to get 90% of it right:
On the second sheet put this formula in G2 and copy it down for as many rows as you have names.
=B2&D2
Put this formula in H2 and copy it down
=F2
On the first sheet put this formula in A2 and copy it down
=VLOOKUP(D2&C2,'second sheet'G:H,2,false)
Any rows where it can't find a matching firstname and surname will have #N/A in them.
Assuming you can modify the second sheet permanently you can put the right surnames in so that the formulae work. You could also put in the middle names into the formulae in case you have two people with the same names.

Related

Excel, how can I link multiple spreadsheets to cells with changing values?

I have a bit of a situation that I can't seem to be able to resolve. I'm currently using excel to keep track and sort 50 patients at the same time for research purposes. So in my main worksheet, A1:A50 are the patient's "station number" and B1:B50 are the patient's names. Columns "C" through "I" contain information about each patient (sex, gender, ecc.). I keep the patients sorted by their station number.
I then have a different worksheet for every patient in which I keep track of each patient's blood tests during time.
I'm trying to find a way so that I can click on a certain patient and get re-directed to his/hers bloodtest worksheet. And I've done so with hyperlinks. The problem is that patients constantly change, as do their station numbers.
For example, patient John Doe has "station number" 001, so he is on the top of my list. His station might change the week after to 005, so I manually copy/paste his info in row 5. This way, every time I cancel a patient I lose the hyperlink and need to manually search for the worksheet and re-link it to the new patient.
Is there any way in which I can lock a hyperlink to a cell regardless whether or not it is empty? This way I could move patients up and down my chart & change cell values without worrying about messing up the hyperlinks.
I also tried to create a chart with 50 rows in which every time I changed a station number a macro would then sort all the rows. It turned out to be a dead end as I was able only to get the macro to copy/paste the patient's info into the correct row instead of it replacing the row.
Any ideas?
The link below probably has the simplest solution I have seen for creating dynamic hyperlinks based on changing cells.
https://www.extendoffice.com/documents/excel/4030-excel-dynamic-hyperlink-to-another-sheet.html
Also, see this link.
https://excelribbon.tips.net/T013034_Creating_a_Dynamic_Hyperlink.html
Finally, consider this...create a hyperlink that is dynamically linked to a cell value, in which the cell value points to a cell reference within a worksheet, and that when the value is changed can point to a different cell reference.
=HYPERLINK("#Sheet2!A"&Z1)

Find first non-blank cell in column that meets criteria in another column

I've compiled multiple spreadsheets containing sporadic employee information, and I'm now trying to consolidate all of the information to remove duplicates and blanks. The formula below is my starting point, but if the first cell that meets that criteria is blank, it returns a blank. I want it to find the next cell that meets that criteria but has a value.
=INDEX(Working!C:C,MATCH($A3,Working!$B:$B,0))
Below is what the Working tab looks like, which contains the master list of data including blanks and duplicates. Working!C:C is the list of last names; $A3 is the Employee ID I'm hoping to retrieve data for, and Working!$B:$B is the list of Employee IDs. I'll be doing this for many columns, so to illustrate this, in the table example below I've shown that Column D is the phone number. Any help you can provide is appreciated!
Column B-------C-------D
---------287-----Doe----blank
---------287-----blank---333-333-3333
---------287-----Doe----blank
Use the following array formula:
=INDEX(Working!C$1:C$100,MATCH(1,($A3 = Working!$B$1:$B$100)*(Working!C$1:C$100<>""),0))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.
Please note that with an array formula the references need to be the smallest range possible that covers the dataset.

Linking Data from One sheet into another on DropDown selection

I am trying to create a Monthly Net Income/Expense Sheet.
I have a small manufacturing firm and based on orders we receive i want to add monthly Expense and Income.
I have created a small sheet
I have 3 sheets right now
Orders List basically has Names of all orders i receive for example Washing Unit. I have defined a name so that it will be a drop down selection as can be seen in image as Order Name
Now my Washing Unit is EXACTLY same as this sheet except it doesn't have Order Name
I want to know if I select Washing Unit from Dropdown how can I link the entire Row data into my Washing Unit Sheet
e.g if I put Description and date,income and expense and then i select Washing Unit, it should be added as an entry in Washing Unit sheet and if I select None it will be removed from there
So long as you wish to extract data from a single cell in another sheet the best way to do it should be using the INDEX/MATCH worksheet function.
Do you have some code of your own that you've tried? I suggest you try writing some then come back for help to perfect it.
Some hints:
Use the worksheet_change event of sheet "Jan".
To reliably identify rows to add or remove, you need another field in "Jan" and "Washing Unit" - let's call that "Order Number". It doesn't have to be fancy, it just has to uniquely identify each order.
You set worksheet_change to check for changes in the "Order Name" column. If it finds one, it grabs the order number from the changed row and looks for that order number in the "Washing Unit" sheet.
If "Order Name" is "None" it deletes any rows with that order number from "Washing Unit".
If "Order Name" is "Washing Unit" and the order number is not found, it finds the first empty row in "Washing Unit" and adds the order there.
Edited to add:
That should be 'If "Order Name" is NOT "Washing Unit" it deletes any rows with that order number from "Washing unit".'
Changed because it occurred to me you might have other order names and from time to time you might need to correct an incorrect order name.
But you still need to write your own code!
Without seeing the which columns you have your data under, A, B, C etc. I'm not able to create something that will definately work on your sheet but the formula below is what myself and Variatus are suggesting you use.
=IFERROR(INDEX(Jan!$A$1:$E$1000,SMALL(IF(Jan!$D$2:$D$1000="Washing Unit",ROW(Jan!$A$2:$A$1000)),ROW(1:1)),2),"")
What you can create with a formula like this is a dynamic filtered version of the data you have on your sheet Jan so that as you add "Washing Unit" entries they will be autimatically listed on the Washing Unit sheet.
The fomula is looking at the whole table of data on sheet Jan and then it is comparing the data in column D Jan!$D$2:$D$1000="Washing Unit" to see if it contains "Washing Unit". This formula would be placed at the top of sheet Washing Unit and it displays the first match ROW(1:1) and takes the data from the second column of the specified range ROW(1:1)),2),"") so you put the formula under the corresponding column in your Washing Unit sheet.
Once you have entered the formula you must use CTRL+SHIFT+ENTER instead of just ENTER to make it an array formula and add {}. You can then drag the formula down as many cells as you think you might need. (You'll see the data in the cells as you do this).
Then, go back to the top and copy the first cell over to the next column and change the number in the formula that specifies the column you want to extract data from ROW(1:1)),2),"") to 3 of the number that corresponds with your heading and again use CTRL+SHIFT+ENTER to add the curly brackets {} and auto-fill down again.
Repeat until you have all the columns you need.
It's not an easy formula and you need to remember the CTRL+SHIFT+ENTER to ensure that it works but you can have a go and see if you can get it working.

CheckBox to limit a data validation list

Moving forward, slowly.......
I added a column, that with the combination of my checkboxes, gives the name of active employees.
Screen Shot of active list of employees
If I use $T$6:$T$16 as my validation list, I still get 11 options in the drop down. I want the drop down to show only the 5 names that are in that list.
No need to use VBA here, Here's a quick solution.
Use a 1 or 0 in a column next to the employees' names corresponding to whether they are active or not.
Then create a column in the sales sheet which has a vlookup for this value
=VLOOKUP(E4,$A$4:$B$8,2,FALSE)
This looks for value E4 (the name), in range of all names, second column for their active status, FALSE for an exact match.
Then use a filter:
Highlight range of sales
"Data" tab
"Filter"
Then you can use the filter on the new Active column to only show the employees which are still active. See the linked image for the final outcome. The vlookup lives in column D.
Final outcome image in Excel
Of course if you want this in two sheets, you can split what I've done to different sheets with no extra effort other than adding sheet references to the range in the vlookup.
Hope this helps

How to look for a value in a sheet, but it may be in different columns, and the copy pasted in another sheet if match some criteria?

here is my issue.
I have 2 sheets in the same workbook that share a common criteria (po#).
*Sheet1: contains the information that has to be filtered and divided according to sheet3... that is if the PO# in sheet1 match the po# in sheet3 then the whole row should be copy and pasted in a "sheet4" if meets some criteria ("market" that could be jet, bigcommerce, amazon). Here is where it gets more complicated...
1-the po# in sheet3 is in the first column (A), but the po# in sheet1 is in column A or B.
2-The idea is to have one sheet for each market.
So excel should look for the po# first, and the if its there, look for "market" and copy paste all the records that share the same market in another sheet.
*Sheet3: contains po# and some other data.
--Other user asked a similar question (find record and copy pasted in another sheet) but the answer is based on the lookup value being in only one column (as opposed to my case where it may be in A or B). how can I make it look in both columns?
Thank you!
Because your two search columns are in the same data table as your results, your solution is actually quite straightforward, using a combination of the INDEX & MATCH functions. INDEX pulls in the value for a column, for a specified row #. MATCH provides the row number, where a search term was found in a column. Together, they work like this, pulling in the amount in column D, for the row where column B matches the search term in A1:
=INDEX(D:D,MATCH(A1,B:B,0))
For your case, you simply need to use IFERROR to first try to match the search term in one column, and then if no match is found, try to match the search term in a second column. Put this formula in your sheet1, starting at B2 [assuming no headers], and then drag down and to the right:
=INDEX('Sheet3'!B:B,IFERROR(MATCH('Sheet1'$A2,'Sheet3'!$A:$A,0),MATCH('Sheet1'$A2,'Sheet3'!$B:$B,0)))