In the workbook there are 2 sheets
1)Postawardlog and 2) budget posted in EIS
Our task:
ACCOUNT in sheet1 and Projectid in sheet2, TOTAL in sheet1 and Amount in sheet2 are columns which needs to be compared. We need to display o/p in sheet3 for only which are not matching. Please see the project1 word document attached for details. I am also attaching the code which i have.
I am trying it and not able to solve. please send me the macro code as reply or mail me at [email protected]. Thank you in advance.
I am posting the code which i have but it is having some errors.
Sub combine_data()
Dim DestCell As Range, SourcE1 As Range, sourcE2 As Range, FirstCell As Range, cc As Range, ffound As Boolean
Set SourcE1 = Sheets(1).Range("a2") ' 1st data cell of 1st list
Set sourcE2 = Sheets(2).Range("a2") ' 1st data cell of 2nd list
Set DestCell = Sheets(3).Range("a2") 'cell to copy the combined table to
Set FirstCell = DestCell
Do While SourcE1 <> ""
DestCell = SourcE1
DestCell.Offset(0, 1) = SourcE1.Offset(0, 1)
Set DestCell = DestCell.Offset(1, 0)
Set SourcE1 = SourcE1.Offset(1, 0)
Loop
Do While sourcE2 <> ""
For Each cc In Range(FirstCell, DestCell)
ffound = False
If cc = sourcE2 Then
cc.Offset(0, 2) = sourcE2.Offset(0, 1)
ffound = True
GoTo nxt
End If
Next cc
If ffound = False Then
DestCell = sourcE2
DestCell.Offset(0, 2) = sourcE2.Offset(0, 1)
Set DestCell = DestCell.Offset(1, 0)
End If
nxt:
Set sourcE2 = sourcE2.Offset(1, 0)
Loop
For Each cc In Range(FirstCell, DestCell.Offset(-1, 0))
cc.Offset(0, 3).FormulaR1C1 = _
"=IF(RC[-1]="""",""not present in sheet 2"",IF(RC[-2]="""",""not present in sheet 1"",IF(RC[-2]<>RC[-1],""values mismatch"","""")))"
Next cc
End Sub
Bookmarks