ForEach procedure adding values
Dim rng as Range, rng1 as Range, cell as Range
Dim res as variant
With Worksheets("Output")
set rng = .Range(.Cells(1,1),.Cells(rows.count,1).End(xlup))
End With
With Worksheets("Input")
set rng1 = .Range(.Cells(1,1),.Cells(rows.count,1).End(xlup))
End With
for each cell in rng
res = Application.Match(cell,rng1,0)
if not iserror(res) then
cell.offset(0,1).Value = _
rng1(res).Offset(0,1).Value
End if
Next
--
Regards,
Tom Ogilvy
"Mats Westin" wrote in message
...
Hi,
I've done a ForEach procedure that updates an output list
(based on names in column A, sheet Output) based on a
database (names in column A and values in column B, Sheet
Input).
If there are two identical names in the "database", I want
to add those values in the Output sheet for that name.
(Now I only get the last number in the database)
I appreciate any suggestion how to solve this?
Thanks!
Mats Westin
|