Sunday, September 23, 2012

How to Compare Files in Microsoft Excel


Compare by Size
1. Save the file in comma separated values format. Use similar file names, such as file1.csv and file2.csv. This method only works for worksheets containing data, not formulas.
2. Go to the start menu and select 'Accessories,' select 'Command Prompt.'
3. Change the directory of the command prompt to the directory where the files are stored. For example, it will start with 'C:\Users\Joe.' Type 'cd Documents' to work within the Documents folder; the directory prompt will then read 'C:\Users\Joe\Documents.'
4. Type 'comp file1.csv file2.csv' using your filenames from the folder where the files are stored. If they are the same size, command prompt will assume they are the same and tell you that 'Files compare OK.' If they are not, command prompt will advise 'Files are different sizes.'
Compare Lists With a Macro
5. Open the Visual Basic Editor and select the primary file from the left menu as VBAProject[file1.xlsm].' Select 'Insert' and 'Module' from the menu at the top.
6. Create a macro in visual basic that will run through an if/then loop comparing the text of each cell in the primary file with a secondary file. Give it a logical name, such as 'CompareFiles().' The code must output a list of data that is different in a new sheet in the primary file. Close the Visual Basic Editor and save the file.
7. Click on the 'View' tab at the top of the main navigation; Select 'Macros' and then 'View Macros.' Select the new macro from the list and click 'Run.'

Blogger news