I have many workbooks (monthly home accounts) that have the same named ranges. I use a function to perform sumif
Debit = Application.SumIf(.Range(Codename), Cellpos, .Range(Drname))
where Codename is a named range of code letters, Cellpos is the specific codeletter I want to sum and the range to sum over is Drname. This works fine when only one workbook is open at a time, but when two or more are open the function appears to get confused which workbook I am referring to - all hell breaks out! How can I be more specific? I can use the workbook name & worksheet name if I could only figure the syntax! The Full Function is this
Function Diff02(Codename As String, Drname As String, Crname As String, Shtname As String, Cellpos As String) As Single
Worksheets(Shtname).Activate
With Sheets(Shtname)
Debit = Application.SumIf(.Range(Codename), Cellpos, .Range(Drname))
Credit = Application.SumIf(.Range(Codename), Cellpos, .Range(Crname))
Diff02 = Debit - Credit
End With
End Function
```