Nader
01-13-2008, 08:33 AM
I tried to insert the Sumif function in sheet3's column2 to sum the cells in sheet2's column2, comparing with the match between the cells in sheet2's,column1 with sheet3's column1.
it's mean if data in sheet's2 column1 george,john,jeny,george,jeny - column2 ,2,4,5,4,8
and the data in sheet3's column1 has the same data .Sumif function will show the result (of sum the number in sheet2's column2) in the sheet3's column2 .
Dim cell As Range, cel As Range
Set myRange3 = Worksheets(2).Range("A1:A100")
Set myRange4 = Worksheets(2).Range("b1:b100")
For Each cell In myRange3
For Each cel In Sheets(3).Range("a1:a100")
If cel.Value = cell.Value And cell.Value <> "" Then
cel.Offset(0, 1).Value = "=SUMIF(A1:a100," & cell.Address & ",B1:b100)"
End If
Next
Next
The Sumif doesn't work well .
it's mean if data in sheet's2 column1 george,john,jeny,george,jeny - column2 ,2,4,5,4,8
and the data in sheet3's column1 has the same data .Sumif function will show the result (of sum the number in sheet2's column2) in the sheet3's column2 .
Dim cell As Range, cel As Range
Set myRange3 = Worksheets(2).Range("A1:A100")
Set myRange4 = Worksheets(2).Range("b1:b100")
For Each cell In myRange3
For Each cel In Sheets(3).Range("a1:a100")
If cel.Value = cell.Value And cell.Value <> "" Then
cel.Offset(0, 1).Value = "=SUMIF(A1:a100," & cell.Address & ",B1:b100)"
End If
Next
Next
The Sumif doesn't work well .