VBA: Probleme using data from another excel file
Hi, I've been trying to do a sumif with data from another excel file, I want to sum data from the other fille with a criteria based on dates from this same other file here's what i've done, but i get a error 13 type mismatch:
Private Sub Workbook_Open()
Dim XL As Excel.Application
Dim WBK As Excel.Workbook
'Date for comparision criteria
Set DateAc = Sheets("06-17").Range("E8")
Set XL = CreateObject("Excel.Application")
Set WBK = XL.Workbooks.Open(ThisWorkbook.Path & "\Budget-2013-14.xlsx")
Set Sh = WBK.Sheets("Transactions !")
'Date range and sum range form the other file
Set DateF = Sh.Range("B129:B134")
Set ValeurF = Sh.Range("F129:F134")
sauce = Application.WorksheetFunction.SumIf(DateF, "<" & DateAc, ValeurF) -The probleme is there
WBK.Close False
Set XL = Nothing
End Sub
I tried with a date and sum range from the file i'm working on without problem
I tried to only sum ValeurF without problem
I debbug to check the values contained in DateF and i seemed ok, but it is clearly my dates from the other file that cause the problem... any idea?
EDIT: I did a if and a for instead, saved me a lot of trouble....
Recent comments
5 years 34 weeks ago
6 years 20 weeks ago
6 years 32 weeks ago
6 years 35 weeks ago
6 years 36 weeks ago
6 years 42 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago
6 years 50 weeks ago