+ Reply to Thread
Results 1 to 13 of 13

Excel VBA Run-time error '13' Type mismatch

  1. #1
    Registered User
    Join Date
    03-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Excel VBA Run-time error '13' Type mismatch

    I have an excel sheet which is working on my friends machine but gives "Excel VBA Run-time error '13' Type mismatch" on my machine.
    Its coming while running a macro for a file and same I tried to sent to other colleague and its working fine on his machine. This was just to check if some how file got corrupted. I'm allways getting the following error: Excel VBA Run-time error '13' Type mismatch

    I didn't change anything in the macro so dont know why am I gueting the error.

    Please help me in finding a workaround or a possible solution for the same.

  2. #2
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: Excel VBA Run-time error '13' Type mismatch

    Post the code so we can see and pls highlight the line that gives the error.

  3. #3
    Registered User
    Join Date
    03-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Excel VBA Run-time error '13' Type mismatch

    Thanks for the quick response

    The cell name is "ws5_In_Txt_Required" which is having value as No, but once I press the button which triggers the macro, it takes to the if loop.

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    If Range("ws5_In_Txt_Required") = "Yes" And (Range("ws23_Out_Date_StartDate") > Range("ws23_Out_Date_EndDate")) Then
    MsgBox ("Start Date must be before the End Date.")

    error = True

    Else
    .....
    ....
    ...
    End If
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Code written on cell having name as "ws23_Out_Date_StartDate"

    =IF(ws5_In_Int_StartDate="Insert start date below",DATE(YEAR(ws5_In_Date_StartDate),MONTH(ws5_In_Date_StartDate),DAY(ws5_In_Date_StartDate)),'Duration1'!H40)

  4. #4
    Registered User
    Join Date
    03-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Excel VBA Run-time error '13' Type mismatch

    Just to add and the cell "ws5_In_Int_StartDate" is blank

  5. #5
    Registered User
    Join Date
    03-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Excel VBA Run-time error '13' Type mismatch

    and this same excel is working fine on my collegues machine, i tried almost on 5-7 machines, but only having problem in my machine

  6. #6
    Forum Contributor
    Join Date
    06-16-2011
    Location
    London
    MS-Off Ver
    Excel XP
    Posts
    276

    Re: Excel VBA Run-time error '13' Type mismatch

    Is there a Excel version difference between your machine and your co-workers?

    If not, the "ws5_whatever_whatever".....how is that set?


    Also, instead of posting your code in +++++++++'s, use the tags [ code ] and [ /code ] around it. Like so:

    Please Login or Register  to view this content.
    The mods are kinda hot on the correct use of [ code ] tags in here....

  7. #7
    Registered User
    Join Date
    03-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Excel VBA Run-time error '13' Type mismatch

    Below is the error message appears in the excel when I run the macro button:

    Macro_error_Excel.jpg
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

    Line where it points to debug: ==> The first line in the code with "If" loop

    Please Login or Register  to view this content.
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Code written on cell having name as "ws23_Out_Date_StartDate"

    =IF(ws5_In_Int_StartDate="Insert start date below",DATE(YEAR(ws5_In_Date_StartDate),MONTH(ws5_In_Date_StartDate),DAY(ws5_In_Date_StartDate)),'Duration1'!H40)

    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Values in cell : ws5_In_Txt_Required
    Its a List box where there are only 2 options "Yes" or "No"
    While we type "No" still it gives the same error on same line mentioned above.
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Value in cell : ws5_In_Int_StartDate. This is also a list box with default value as "End of deployment phase"
    But the value should not matter if the value in above cell i.e. Ws5_In_Txt_Required is "No"
    And Similarly with cell "ws5_In_Date_EndDate". Value in this cell is only required if cell "Ws5_In_Txt_Required" does'nt have value as "No"
    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

  8. #8
    Registered User
    Join Date
    09-20-2011
    Location
    UK
    MS-Off Ver
    Excel 2007
    Posts
    43

    Re: Excel VBA Run-time error '13' Type mismatch

    The way this line is written:
    Please Login or Register  to view this content.
    The macro will always evaluate whether Range("ws23_Out_Date_StartDate") > Range("ws23_Out_Date_EndDate") even if Range("ws5_In_Txt_Required") ="No". So it is creating an error because these fields contain text rather than a valid date. If you want to compare start date and end date make sure users can only specify a valid date. If you only want to compare start date and end date if the first field is equal to yes then change the code to look like this. You can also use IsDate to test the date fields before comparing them to avoid the error occuring.
    Please Login or Register  to view this content.

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Excel VBA Run-time error '13' Type mismatch

    are you sure there are no error values in any of the three cells on your machine?

  10. #10
    Registered User
    Join Date
    03-30-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Excel VBA Run-time error '13' Type mismatch

    Problem has been resolved now. Thanks a lot.

    The problem was on date format of my laptop.
    Date on my machine was set to US date format and in the excel macros were taking date format as British date format.

    Thanks for all your support in helping me.

  11. #11
    Registered User
    Join Date
    07-02-2012
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Excel VBA Run-time error '13' Type mismatch

    Hi all, first post for me.

    Please help!

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Check if value = "Paid"
    If Target.Value = "Paid" Then
    'Turn off events to prevent recursive calls
    Application.EnableEvents = False
    'Copy row to new worksheet
    Target.EntireRow.Copy
    With Worksheets("GR & Sent for Payment")
    .Range("A" & .Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteAll
    End With
    'Delete the source row
    Target.EntireRow.Delete
    'Turn events back on
    Application.EnableEvents = True
    End If
    End Sub


    I get a runtime error type 13 mismatch on the above code.

    Debug points to line 3

    I want the macro to move one line from a worksheet to another when the text entered is 'Paid'

    Hope you guys can help!

    thanks

  12. #12
    Registered User
    Join Date
    12-17-2013
    Location
    Riyadh
    MS-Off Ver
    Excel 2007
    Posts
    18

    Re: Excel VBA Run-time error '13' Type mismatch

    HI all,

    I have a VBA code when try to run it is giving the error as: Run-time error '13' Type mismatch. this is a code about entering the data on the sheet from user form. I don't know where the code gotten wrong..

    can anyone help me with this issue..

    Pls find the attached file for your reference.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by arlu1201; 12-27-2013 at 05:33 AM. Reason: Edited code tags.

  13. #13
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Excel VBA Run-time error '13' Type mismatch

    meer_ali,

    Unfortunately you need to post your question in a new thread, it's against the forum rules to post a question in the thread of another user. If you create your own thread, any advice will be tailored to your situation so you should include a description of what you've done and are trying to do. Also, if you feel that this thread is particularly relevant to what you are trying to do, you can surely include a link to it in your new thread.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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