SUMIF formula doesn't give the correct answer in excel vba -
i'm using sumif formula gives me wrong output. can me? have checked lot of times unable find mistake! in advance!
range("b10", range("b10").offset(0, -1).end(xldown).offset(0, 1)).formula = _ "=sumif('[" & dest_name & "]cu part pvo l'!$m$10:$m$2000,a10," & _ "'[" & dest_name & "]cu part pvo l'!$ad$10:$ad$2000)" [output][1]
to clarify vba approach here's rough out:
dim long dim wb workbook set wb = applications.workbooks.open(dest_name) 'dest_name need full file 'path, i.e. c:\<folder 1>\<folder 2>\....\<file name>.<file extension> dim cppl worksheet set cppl = workbooks(dest_name).worksheets("cu part pvo l") dim v string 'change type based on what's in a10 v = range("a10").value dim t long = 10 while < 2001 if cppl.range("m" & i).value = v t = t + cppl.range("ad" & i).value end if = + 1 loop range("b10", range("b10").offset(0, -1).end(xldown).offset(0, 1)).value = t
as added bonus, way, if dest_name isn't open values still display instead of erroring.
Comments
Post a Comment