+ Reply to Thread
Results 1 to 13 of 13

Excel - Compare data based upon specific criteria split into columns and delimiters

  1. #1
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Excel - Compare data based upon specific criteria split into columns and delimiters

    Hi all,

    I am a new member here and I hope you will be able to help me out on my requirement. I need to automate an excel report which will contain IT infrastructure data. There are 3 main columns or headers: "SERVERS", "PORTS" and "SWITCHES".

    The idea is to test and compare this data based upon specific criteria and then returning the appropriate results. The data in "PORTS" column is interdependent to data in "SWITCHES" column. Data is split within cells by delimiters. If the ports are connected to different Switches, I expect to get the result "OK = Redundancy exist", otherwise "NOK = Single Point of Failure".

    To give you a better understanding, I have given you below a few examples.

    ----------

    1. Example1 in Row2

    CellA2 = Server_FRANCE
    CellB2 = NIC1 | NIC2 | ILO
    CellC2 = SwitchA | SwitchA | SwitchB

    - Note: The values in B2 are interdependent with values of C2, that's the reason why we have delimiters (NIC1 | NIC2 belong respectively to the same Switch A and ILO to SwitchB). The name of ports and switches have been chosen for example. They will vary depending on the servers and switches.

    - Need: Only apply test on ports NIC1 and NIC2 and compare if they are connected or not to the same SwitchA. (ILO out of scope all the time but need to be displayed in "PORT" column).

    - Result expected: Here, the result will be "NOK" as we don't want to have the ports NIC1 and NIC2 connected to the same Switch.

    ----------
    2. Example2 in Row3

    CellA3 = Server_UK
    CellB3 = NIC1 | ILO | NIC2 | NIC3
    CellC3 = SwitchA |SwitchA | SwitchB | SwitchC

    - Note: Here, the position of ILO is after the 1st delimiter. Once again, The values in B3 are interdependent with values of C3 meaning that NIC1, NIC2 and N3 belong respectively to Switch A, SwitchB and SwitchC. ILO is out of scope all the time but need to be displayed in "PORT" column. The name of ports and switches have been chosen for example. They will vary depending on the servers and switches.

    - Result expected: "OK" (as we want the ports connected to different switches).

    ----------
    3. Example3 in Row4

    CellA4 = Server_Australia
    CellB4 = ETH0 | ETH1 | ILO | ETH2
    CellC4 = SwitchA | SwitchA | SwitchB | SwitchA

    - Need: Tests on all ports (except ILO but it needs to be displayed in port column). The name of ports and switches have been chosen for example. They will vary depending on the servers and switches.

    - Result expected: "NOK" (as the ETHO and ETH1 and ETH2 ports are connected to the same SwitchA).

    ----------

    4. Example4 in Row5

    CellA5 = Server_India
    CellB5 = ETH0 | ETH1 | ETH2
    CellC5= SwitchA | SwitchA | SwitchB

    - Note: Sometimes we have a few cases where the ILO port is not present. Test will apply on the available ports.
    - Result expected: "OK".


    Apologies in advance for being sometimes a bit repetitive as I couldn't attach any spreadsheet.
    Thanks a lot for sharing your ideas.

    Regards,
    Mike
    Last edited by Funkadlic01; 12-24-2016 at 08:29 AM.

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Question.

    Why is Example 4 "OK"?

    ETH0 & ETH1 share SwitchA. Should it not be "NOK"?

  3. #3
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Hi CK76 - Indeed, you are right, I have just corrected that mistake. "OK" only if the ports don't share the same switch.

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Here you go. Test it with your real data and check if it returns right result. Took about 22 sec for 10k+ rows.
    Note that you must run this code while you have the sheet with data active.

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

  5. #5
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Hi CK76 - First, thanks for your help. I have ran your code in my spreadsheet, but it returns "NOK" instead of "OK" for a few servers. I have attached a screenshot of my spreadsheet:

    Capture.JPG
    Last edited by Funkadlic01; 12-24-2016 at 01:45 PM.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Hmm, you need to explain the logic better.

    For Australia, ETH0 and ETH2 share SwitchA
    For Canada, NIC2 & NIC3 share SwitchB
    For ABC123, ETH0 & ETH1 share SwitchA

    Shouldn't these all be NOK?

  7. #7
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    The logic behind is to test from a server perspective whether all its ports (except ILO) share the same switch or not for redundancy purposes.
    It doesn't matter that we have several ports sharing the same switch as long as there is at least one sharing another switch (except ILO), the result expected must return "OK".

    For Australia, ETH0 and ETH2 share SwitchA, but we have also ETH1 port which is connected to SwitchB -> Thus, the server_Australia is connected to 2 switches => "OK" as the server_Australia has redundant connections with SwitchA & SwitchB.

    Hope that my sounds clear. Thanks again.
    Regards,

    Mike

  8. #8
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Ok then try attached. I tried posting code itself. But won't allow me for some reason.

    Slightly altered logic and uses dict.count as check.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    CK76 - I have ran your code on a few rows and it does work perfectly.
    Good job! Much appreciate it! Happy Xmas!

  10. #10
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Hi CK76 - You've already been helpful. Would you please be able to add some comments in your code to understand the main functions as I am learning VBA. But, no rush it's not really urgent.

    Thanks a lot.
    Regards,

    Mike

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Ok. I'll try to break it down and give you explanation. In the mean time read the links. It will introduce you to two main components used in this code (array and Scripting.Dictionary).

    http://analystcave.com/excel-vba-dic...ta-structures/
    http://analystcave.com/vba-vba-array/

  12. #12
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Here you go. Please see attached. Added comment to the code (unable to paste the code as it gives me SQL injection violation).
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    12-23-2016
    Location
    Brisol
    MS-Off Ver
    MS Office 2010
    Posts
    7

    Re: Excel - Compare data based upon specific criteria split into columns and delimiters

    Hi CK76 - That's very kind of you. Thanks a lot for sharing this and once again thanks for your help. Happy New Year 2017!

    Regards,
    Mike

+ 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. Split data by delimiters but by formula (not Text to Columns)
    By STUARTXL in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-19-2016, 05:44 AM
  2. [SOLVED] Split Excel Sheet Data into mutliple files based on two criteria
    By saleembasha in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2016, 12:14 PM
  3. Replies: 7
    Last Post: 04-29-2016, 12:25 AM
  4. [SOLVED] Macro to split data onto new sheets based on specific column
    By pauldaddyadams in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-17-2015, 12:53 PM
  5. I would like to split one worksheet into many files based on criteria in two columns
    By paulfields4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2015, 07:34 PM
  6. Excel VBA Macro - Deleting Specific Data based on criteria
    By MD011 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-08-2014, 01:06 PM
  7. Replies: 2
    Last Post: 04-09-2014, 11:48 AM

Tags for this Thread

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