Wednesday 11 April 2012

Compare Cells in single excelsheet


Set obj=createobject("excel.application")
obj.visible=true
Set obj1=obj.workbooks.open("E:\sac2.xls")
Set range1=obj1.worksheets(1).range("A1:B7")
Set range2=obj1.worksheets(1).range("C1:D7")

r1=range1.rows.count
c1=range1.columns.count
For i=1 to r1
For j=1 to c1
If range1.cells(i,j).value<>range2.cells(i,j).value Then
range1.cells(i,j).interior.colorindex=6
End If
Next

Next
obj1.save
obj1.close
obj.application.quit

OutPut :Here i compared cells between the range A1:B7 and C1:D7

3 comments:

  1. great but if i have more cell like, comparing A to B, C to D, E to F, G to H how could i do that please help

    ReplyDelete
  2. great but if i have more cell like, comparing A to B, C to D, E to F, G to H how could i do that please help

    ReplyDelete
  3. Ti-Titanium-Arsenic Thoroughbred | Titanium Art
    The Titanium-Arsenic Thoroughbred is titanium exhaust wrap the exact same titanium blue ps4 controller as the microtouch titanium trim walmart other Thoroughbreds. Thoroughbred Thoroughbred's Thoroughbreds are a very diverse titanium pipe group that is does titanium set off metal detectors

    ReplyDelete