+ Reply to Thread
Results 1 to 10 of 10

Compare Two Sheets, Copy Data

  1. #1
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Compare Two Sheets, Copy Data

    Hello everyone. I have one for you. Attached are Alert.csv and tracking.xlsx. What I am trying to do are two things.

    1 - Alert.csv columns A (First Name), B (Last Name), C (User Email), D (Device Name) and U (OS Name) need to be compared to the data in Tracking.xlsx, and if the data of Alert columns A and B (or C if it's easier) is NOT present in Tracking, then I need Alert columns A, B, C, D and U copied to Tracking columns A, B, C, D and E on the first available row (currently 21).

    2 - In Alert.csv, columns F, G, H, I, J, K, L, M, N, O, S and T will contains values of either PASS, FAIL, WARNING or NA. If the values are either FAIL or WARNING I would like the title of that value listed in column X.
    For example - Row 16, Preston Soloff has either a warning or fail on: Password, Anti-Spyware, Disk Encryption. So in X16 I would like that cell to read "Password, Anti-Spyware, Disk Encryption".

    Is this possible? I would really appreciate any help!
    Last edited by mightymo77; 12-17-2021 at 02:05 PM.

  2. #2
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Compare Two Sheets, Copy Data

    I think a good solution would be using Power Query, but there is a column header adjustment that need to be decided, it is easy to solve, but it is you who has the last say.
    The .csv is imported directly to Power Query and then appended to the named table in Tracking.xlsx, then filter column D for unique value.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Compare Two Sheets, Copy Data

    I will need to figure out how to apply that code in Power Query. Never used it before. I also noticed a typo in your code "Traking" just fyi.

  4. #4
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Compare Two Sheets, Copy Data

    Quote Originally Posted by mightymo77 View Post
    I will need to figure out how to apply that code in Power Query. Never used it before. I also noticed a typo in your code "Traking" just fyi.
    misspell, that happens...

    Power Query is very good and simple tool to work with data, is the same tool of Power BI, so learning it in Excel also gives you knowledge in Power BI.
    The code really represent 3 pressed buttons, is a requirement of the forum to show it, you don't white this thing.
    Once you start using it you don't stop, lots of videos about it in Youtube, highly recommend!

    An introductory video about it:
    How Power Query Will Change the Way You Use Excel
    Last edited by DJunqueira; 12-15-2021 at 06:03 PM.

  5. #5
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Compare Two Sheets, Copy Data

    OK thank you. I don't have that much time (right now) to figure out how to use Power Query.

    Back to my two questions in the first post, is there a formula that can resolve question #2? That is the very time-consuming procedure, so if there is a formula that I can use that would be great.

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Compare Two Sheets, Copy Data

    Quote Originally Posted by mightymo77 View Post
    Back to my two questions in the first post, is there a formula that can resolve question #2? That is the very time-consuming procedure, so if there is a formula that I can use that would be great.
    In X2 of Alert File then copied down. ARRY formula used.

    =TEXTJOIN(", ",TRUE,IF(ISNUMBER(FIND($F2:$T2,"FAIL,WARNING")),$F$1:$T$1,""))

    To enter ARRAY formula
    Copy and paste the formula in cell
    Press F2
    Press Ctrl+Shift+Enter together
    Excel covers the formula with {}.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  7. #7
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Compare Two Sheets, Copy Data

    Hey guys. Using kvsrinivasamurthy's solution above, works great on my home machine (Excel 2021), however on my work machine (Excel 2016) using the same exact .csv file, it is not working and producing a #NAME? error. Any ideas?

    EDIT - I looked into it and TEXTJOIN apparently does not work on Excel 2016. I think maybe If(LEN may work? Can anyone change kvsrinivasamurthy's formula to one that functions in Excel 2016? Thank you for your help!
    Last edited by mightymo77; 12-16-2021 at 12:38 PM.

  8. #8
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Compare Two Sheets, Copy Data

    If TEXTJOIN Is not working it is better to go for UDF. I will give code for that. The file is to be saved as .xlsm not as .csv.
    Code for UDF
    Please Login or Register  to view this content.
    How to Use UDF code:
    In the developer tab click--> Visual Basic
    VB window opens
    Insert--> Module
    Paste the code.
    Close the VB window.
    Now UDF is available in Function List
    Last edited by kvsrinivasamurthy; 12-17-2021 at 03:59 AM.

  9. #9
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,744

    Re: Compare Two Sheets, Copy Data

    Power Query is a free AddIn for Excel 2010 and 2013, and is built-in functionality from Excel 2016 onwards (where it is referred to as "Get & Transform Data").

    It is a powerful yet simple way of getting, changing and using data from a broad variety of sources, creating steps which may be easily repeated and refreshed. I strongly recommend learning how to use Power Query - it's among the most powerful functionalities of Excel.

    - Follow this link to learn how to install Power Query in Excel 2010 / 2013.

    - Follow this link for an introduction to Power Query functionality.

    - Follow this link for a video which demonstrates how to use Power Query code provided.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  10. #10
    Registered User
    Join Date
    10-29-2021
    Location
    USA
    MS-Off Ver
    O365
    Posts
    51

    Re: Compare Two Sheets, Copy Data

    Thank you all for the excellent assistance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Compare two sheets and copy data from sheet to another.
    By HXIO in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2018, 07:03 AM
  2. [SOLVED] Compare two rows of data in separate sheets then copy data
    By symaxf in forum Excel General
    Replies: 6
    Last Post: 07-30-2018, 09:41 PM
  3. [SOLVED] Compare names and copy data on two sheets
    By sprit36 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-27-2017, 08:51 AM
  4. [SOLVED] Macro to compare data between sheets and copy/paste
    By ScabbyDog in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-24-2012, 05:46 PM
  5. compare data in 2 columns across 2 sheets and then copy data
    By CH53 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2011, 04:59 AM
  6. Compare 2 sheets & copy unmatched data below
    By tek9step in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2010, 10:57 AM
  7. Compare a value with value in other sheets and then COPY data into a sheet.
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-28-2009, 03:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1