Excel Compare

  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Excel Compare as PDF for free.

More details

  • Words: 281
  • Pages: 1
ExcelCompare.vbs 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

5/17/2009 11:42 PM

'######################################################### 'ExcelCompare.vbs 'Author: Vishnu Agrawal '######################################################### option explicit dim dim dim dim dim dim

args ExcelFilePath1, ExcelFilePath2 fso, objExcel objWorkbook1, objWorkbook2 objWorksheet1, objWorksheet2 cell, DiffCount

args = WScript.Arguments.Count If args < 2 then WScript.Echo "usage: ExcelCompare.vbs <ExcelFile1> <ExcelFile2>" WScript.Quit end If ExcelFilePath1 = WScript.Arguments.Item(0) ExcelFilePath2 = WScript.Arguments.Item(1) Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(ExcelFilePath1) = false )Then WScript.Echo ExcelFilePath1 & " doesn't exist." WScript.Quit End If If (fso.FileExists(ExcelFilePath2) = false )Then WScript.Echo ExcelFilePath2 & " doesn't exist." WScript.Quit End If Set objExcel = CreateObject("Excel.Application") objExcel.Visible = false Set objWorkbook1 = objExcel.Workbooks.Open(ExcelFilePath1) Set objWorkbook2 = objExcel.Workbooks.Open(ExcelFilePath2) Set objWorksheet1= objWorkbook1.Worksheets(1) Set objWorksheet2= objWorkbook2.Worksheets(1) DiffCount = 0

For Each cell In objWorksheet1.UsedRange On Error Resume Next If cell.Value <> objWorksheet2.Range(cell.Address).Value Then WScript.Echo cell.Address & " : " & cell.Value & " (" & objWorksheet2.Range(cell.Address) 'Highlights in green color if any changes in cells (for the first file) cell.Interior.ColorIndex = 4 'Highlights the same cell in the Second file objWorksheet2.range(cell.Address).interior.colorIndex = 4 DiffCount = DiffCount + 1 Else cell.Interior.ColorIndex = 0 End If Next WScript.Echo DiffCount & " Cells found." WScript.Echo "Excel Comparison Finished ... " WScript.Echo WScript.Echo "Excel files have been highlighted with green color to show the differences." objExcel.displayAlerts = False objExcel.Save objExcel.Quit set objExcel=nothing Page 1 of 1

Related Documents

Excel Compare
May 2020 5
Excel Compare
November 2019 14
Compare
May 2020 18
Compare
November 2019 28
Compare
April 2020 16