+ Reply to Thread
Results 1 to 1 of 1

VBA: Problem importing date type to another file

  1. #1
    Registered User
    Join Date
    08-13-2013
    Location
    Québec, Canada
    MS-Off Ver
    Excel 2010
    Posts
    1

    VBA: Problem importing date type to another 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, but i'm still interrested in the reason of the error knowing that if I replace the range of date from the other file for a range in the file i'm using, it is working perfectly
    Last edited by mafrej; 08-13-2013 at 05:39 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with importing Date (& time) on CSV file using text to columns and macro
    By Rikkdh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 06:19 AM
  2. Importing .csv file in vba using ADO - wrong data type
    By Andr7ej in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-30-2009, 08:01 AM
  3. Problem importing text file using macro
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-01-2007, 10:21 PM
  4. Problem Importing a TXT File
    By mike in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-11-2005, 06:05 PM
  5. [SOLVED] problem importing data from another file
    By Qaspec in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2005, 09:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1