vba Excel-find same date with match function -
i trying write code find same date , add together 'interestamount' same date, without having separate column of repetition. let's have interestamount $5 on 05/01/2014, if found date 05/01/2014 interestamount $10, add together in old column, new interestamount $15. code wrote not work. note "blah" worksheet original data, want info on sheet "woot". lot help. code.
on excel sheet, sheet "blah" looks this
e v w 1 100000 5/8/2014 6/8/2014 2 100143.14 5/30/2014 6/30/2014 3 7784.73 5/4/2014 6/4/2014 4 100143.14 5/30/2014 6/30/2014 5 100143.14 5/15/2014 6/15/2014
code:
private sub commandbutton1_click() dim interestdate(1 5) date dim interestinterval(1 5) integer dim interestamount(1 5) double dim thedate date dim index variant = 1 5 interestinterval(i) = datediff("d", thisworkbook.sheets("blah").cells(i, 22), thisworkbook.sheets("blah").cells(i, 23)) interestdate(i) = thisworkbook.sheets("blah").cells(i, 23) interestamount(i) = (thisworkbook.sheets("blah").cells(i, 5).value * 0.0237 * interestinterval(i)) / 365 thedate = thisworkbook.sheets("woot").cells(1, i) index = application.match(clng(thedate), range("woot!1:1"), 0) if iserror(index) msgbox "if" msgbox (i) thisworkbook.sheets("woot").cells(1, i) = interestdate(i) thisworkbook.sheets("woot").cells(3, i) = interestamount(i) else msgbox "else" msgbox (index) thisworkbook.sheets("woot").cells(3, index) = interestamount(index) + interestamount(i) end if next end sub
excel vba date excel-vba
No comments:
Post a Comment