How to sum VBA values based on conditions? -
i have following setup:
c1 c2 10 eur 20 gbp 40 eur 60 usd
how can iterate on these cells , sum eur , other currencies?
i assume in column have amount , column b currency; , start row 1:
sub test() dim ws worksheet dim sumeur long, sumothercurrency long set ws = thisworkbook.sheets("sheet1") ws = 1 .range("a" & rows.count).end(xlup).row if .cells(i, "b") = "eur" sumeur = sumeur + .cells(i, "a") else sumothercurrency = sumothercurrency + .cells(i, "a") end if next end msgbox ("sum eur :" & sumeur & vbnewline & "sum other :" & sumothercurrency) end sub
Comments
Post a Comment