Excel VBA. Sum duplicates -
i have table:
column1 | column2 ----------------- name1 | 3,0 name1 | 2,0 name2 | 5,0 name2 | 6,0 etc...
i need vba macros, result in:
column1 | column2 ----------------- name1 | 5,0 name2 | 11,0
steps:
1. sum column2
2. delete duplicates
try below
will put new list in d , e, assumes list on current sheet , in a:b
sub te() range("d1:" & range("e1").end(xldown).address).clearcontents range("a1:" & range("a1").end(xldown).address).copy destination:=range("d1") range("d1:" & range("d1").end(xldown).address).removeduplicates columns:=1, header:=xlno each cell in range("d1:" & range("d1").end(xldown).address) temp = 0 each c in range("a1:" & range("a1").end(xldown).address) if cell.value = c.value temp = temp + c.offset(0, 1).value end if next each c in range("d1:" & range("d1").end(xldown).address) if cell.value = c.value c.offset(0, 1).value = temp end if next next end sub
Comments
Post a Comment