Dear all,
I'm trying to use the SumIf worksheetfunction in VBA, looking in another workbook, but I apparently use the wrong reference. It works without any problem in Excel. I receive the following pop up message : "method range of object worksheet failed"
Here is my code :
Dim i As Integer
Dim SumArg As Variant
Dim File As String
File = "D:\Personal Costs\2013\2. Database\[Personal Costs - 2013-V10.xlsx]"
i = 10
While i >= 10 And i <= 50
SumArg = Application.WorksheetFunction.SumIf(Range(File & "Budget 2013!Q5:Q52"), Range(File & "Budget 2013'!D5:D52"), "B" & i)
i = i + 1
Wend
I understand that to be proper, I should use workbooks(File).worksheets("Budget 2013").range("Q5:Q52"), but I'm afraid that my code will be too long, because I'd like to use many conditions (with SumIfs)...
I already tried many attempts without any success, would you have any idea about my mistake?
Many thanks in advance for your lights.
Best regards,
Eric
Bookmarks