excel - SUMIFS using two Workbooks - Run-time Error "13" -
this first post on stack overflow.. i've used site multiple times vba questions , of time, i've been able find answer. time, however, i'm finding can't locate helps me out. i've tried figure out problem multiple angles , can't seem figure out. i've gotten sumifs code work correctly using single workbook, 2 presents problem. 2 sheets "activehedge.xlsm" , "livedatafeed.xlsm" , here code:
sub call_livedatafeed() workbooks.open filename:="z:\users\toms\desktop\livedatafeed.xlsm" end sub sub createfnma_monthlycoupons() workbooks("livedatafeed.xlsm").activate range("d7").formula = _ "=sumifs('[activehedge.xlsm]active hedge'!$i:$i,'[activehedge.xlsm]active hedge'!$h:$h,">="&u9,'[activehedge.xlsm]active hedge'!$i:$i,"<="&v9,'[activehedge.xlsm]active hedge'!$k:$k,"<"&c5-14)"
so, used & before cell references in criteria range due first 2 criteria being decimals change on "livedatafeed.xlsm" sheet , final criteria date entered in cell, minus 14 days; inputted date change well.
i found sumifs function, entered above, works fine function entered directly worksheet in "livedatasheet.xlsm" workbook. however, when put in vba, has run-time error "13"... solution using 1 workbook, put " " around >= , <= , <... isn't working now... appreciated!
when have formula contains quotes in vba need double them aren't confused quote mark @ end of formula, i.e.
range("d7").formula = _ "=sumifs('[activehedge.xlsm]active hedge'!$i:$i,'[activehedge.xlsm]active hedge'!$h:$h,"">=""&u9,'[activehedge.xlsm]active hedge'!$i:$i,""<=""&v9,'[activehedge.xlsm]active hedge'!$k:$k,""<""&c5-14)"
Comments
Post a Comment