+ Reply to Thread
Results 1 to 15 of 15

Multiple file comparison, and reporting in detail

  1. #1
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Multiple file comparison, and reporting in detail

    Right so the problem is as follows if anybody could give me a few pointers:

    I've what seems like a simple task to do. I'm coding in VBA and want to run a macro such that you identify two folders (each contain the same number of files, with the same name).
    I then want to compare these files(.txt, .xls, .exp, .tab - Issues with file types?) whether that be by parsing the files or by loading them into excel in a temporary sheet, pair by pair and doing some sort of vlookup.

    The point of this is to find any discrepancies and highlight them in a seperate sheet for further analysis. (can the FC function in DOS help at all?)

    If anyone could point me in the direction of a VBA method or a starting point I would greatly appreciate it. Thanks in advance.
    Last edited by VBABen; 06-17-2011 at 09:47 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Brain teaser of a problem - Comparisons

    to compare 2 textfiles in 2 different folders:

    Please Login or Register  to view this content.



  3. #3
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA Brain teaser of a problem - Comparisons

    Thanks snb for the input there, it does compare the files but I need to extend this functionality a lot further.

    I need to be able to check various types of files e.g. .xls, .tab, .exp. I can convert these files to .txt files before the whole process begins which isn't a big issue. The issue is when I want to then highlight the area in the file that doesn't match. I want to create a big report to detail all the files, there status and the unmatched area if there is one.

    Thanks in advanced.

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Brain teaser of a problem - Comparisons

    I did what you asked in your first post.

    Please be more specific, post some example files, and what you want the comparison result to look like.

  5. #5
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA Brain teaser of a problem - Comparisons

    Sorry, I should have explained how I wanted the errors highlighted. I've attached an example of an output report I''m looking for. And pairs of files (1a and 2a are pairs and 1b and 2b are pairs) - These are basic examples.

    As well as checking if the files match I'd like to be able to say where exactly they don't to give the user a better chance of finding the error in the file after. I.e. line number and string of mis match from both files. Could the files themselves be altered when a mis match is found e.g. Set the text that doesn't match to bold or a different colour?



    Thanks in advanced.
    Attached Files Attached Files

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Brain teaser of a problem - Comparisons

    Could the files themselves be altered when a mis match is found
    If you want the files in both folders to be exactly the same, you don't need to compare, but only to copy.....

  7. #7
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA Brain teaser of a problem - Comparisons

    I don't need the files to be the same, I just need to see where there is a difference. What I meant when i said altered is to have an added highlight to the file so the user could spot it straight away. But if I can populate the report description field with a line number and string then I wouldn't need to alter the .txt file.

    In a perfect run all files should report as matched. But I'd like details of when they don't i.e. line numbers and strings.

    Apologies if I'm not being all that clear.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Brain teaser of a problem - Comparisons

    Please Login or Register  to view this content.
    Last edited by snb; 06-17-2011 at 06:33 AM.

  9. #9
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: VBA Brain teaser of a problem - Comparisons

    I'm having problems with the ubound function, how have you declared your variables? namely sn and sq?

    Thanks in advance

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA Brain teaser of a problem - Comparisons

    There's no need to declare any variable.I let the VBA-compiler determine what vartype to use.
    sn, sq and st are variant arrays.The split method produces arrays.

    If you encounter a problem please be as specific as possible: what (kind of) file, which folder, the file content, etc. 'a problem with' doesn't provide an information overload.

  11. #11
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Multiple file comparison, and reporting in detail

    Thanks snb. I'm been stepping through it so I follow your logic. I'll need to clean up the output so if a lot of errors are there it won't generate one long line.

    I was hoping for something along the lines of the output in the attached. Would this just be a case of inserting the correct variable into the desired cell? I'd like to break on a new line with each set of files.

    Thanks in advance, this has really helped me so far
    Attached Files Attached Files
    Last edited by VBABen; 06-17-2011 at 08:50 AM.

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multiple file comparison, and reporting in detail

    I'd like to break on a new line with each set of files
    That's what my macro does.

    What is the use of repeating the identical filenames in column A & column B ?

  13. #13
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Multiple file comparison, and reporting in detail

    In my previous attachment, I've put a line break when the second mismatch is found so you can read it clearly. Your macro didn't seem to do this and only put one long string of detail on the same line. I need it to break per detail then break again per file as it originally does.

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Multiple file comparison, and reporting in detail

    In that case you'll have to adapt the suggestion I made to your 'needs'.

  15. #15
    Registered User
    Join Date
    06-16-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: Multiple file comparison, and reporting in detail

    Ok, I'll keep cracking on with this myself. Thanks for the suggestions, they have been very much appreciated. I'll mark as solved based on my initial description

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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