Create new Excel Worksheet from the common values of one Column.

I would like to take two worksheets (tabs) and create a new third tab.
The code would create the 3rd tab by matching on the common values in the column named "PrimarySmtpAddress".

I have attached a sample file. I saved it as an .xlsx but it can be renamed as a .csv obviously.
Note: the SamAccountName is typically a number at this company but it can also be alphanumeric.

The sample is only 20 rows of data however both tabs will actually have just under 400,000 rows of data when I use the code against it.

I have attached several screenshots and a sample file.

Thank you for your time in advance!


Tab named "wSamAccountName"Tab named "wLastLogonTime"Example of desired results.EE-Sample-Combine-2Tabs-by-Common-Column
K BAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rob HensonFinance AnalystCommented:
You can pull the required data from each tab using a VLOOKUP formula. On the required tab, copy and paste the list of email addresses and then use the following formula, assuming data starts in row 2 on new sheet and screen shots are Sheet1 (email and SamAccount) and Sheet2 (email, login and full name):

Login Time =VLOOKUP($A2,Sheet2!$A:$C,2,False)
User Name  =VLOOKUP($A2,Sheet2!$A:$C,3,False)
SamAccount  =VLOOKUP($A2,Sheet1!$A:$B,2,False)

Copy down the extent of data in column A, or select all 3 and then double click the bottom right corner of highlighted area to fill down.

Rob H

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.