我正在使用这个SUMIF公式,但它给出了错误的输出。有谁能够帮我?我已经检查了很多次但却找不到错误!提前谢谢!
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]
答案 0 :(得分:0)
为了澄清我的VBA唯一方法,这里有一个粗略的说法:
Dim i as Long
DIM wb as Workbook
SET wb = Applications.Workbooks.Open(Dest_Name) 'Dest_name would need to be the full file
'path, i.e. C:\<Folder 1>\<Folder 2>\....\<File Name>.<file extension>
Dim CPPL as Worksheet
Set CPPL = Workbooks(Dest_Name).Worksheets("Cu Part PVO L")
Dim v as String 'change the type based on what's in A10
v = Range("A10").Value
Dim t as long
i = 10
Do While i < 2001
If CPPL.Range("M" & i).value = v THen
t = t + CPPL.Range("AD" & i).value
End if
i = i + 1
Loop
Range("B10", Range("B10").Offset(0, -1).End(xlDown).Offset(0, 1)).Value = t
作为额外的奖励,这样,如果Dest_Name未打开,则值仍将显示而不是错误。