+ Reply to Thread
Results 1 to 11 of 11

VBA Code Run-time Error 13 - Type mismatch

  1. #1
    Registered User
    Join Date
    08-17-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    14

    Question VBA Code Run-time Error 13 - Type mismatch

    I have the following code in a specific worksheet:

    Private Sub Worksheet_Change(ByVal Target As Range)

    If Target.Address = "$G$456" And Target.Value = "X" Then

    Call PhoneSecuredapproval

    End If

    It worked fine until a few days ago when I copied and pasted something (not in an area where this points). Since then if I hit delete anywhere in this particular sheet, I get the error. How can I stop this from happeneing?

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code Run-time Error 13 - Type mismatch

    Can you please attach the workbook...?

  3. #3
    Registered User
    Join Date
    08-17-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    14

    Talking Re: VBA Code Run-time Error 13 - Type mismatch

    Attached. . .
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-17-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: VBA Code Run-time Error 13 - Type mismatch

    Attached to thread. . .

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: VBA Code Run-time Error 13 - Type mismatch

    Hi,

    The code isn't working because the Target cell is always going to be where the drop-down list is (L3). Your 2 best options would be:
    1. Move the code to the Worksheet_Calculate subroutine
    2. Use this code instead:
    Please Login or Register  to view this content.
    Hope this helps

  6. #6
    Registered User
    Join Date
    08-17-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: VBA Code Run-time Error 13 - Type mismatch

    I sure appreciate your response, however I am not sure that you are looking at the same code? The code I am referring to is on Sheet7 (Underwriter) and points to items in columns G and X.

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

    Re: VBA Code Run-time Error 13 - Type mismatch

    there is no such sheet in the workbook you provided

    nevertheless you can use syntax akin to
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  8. #8
    Registered User
    Join Date
    08-17-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    14

    Thumbs down Re: VBA Code Run-time Error 13 - Type mismatch

    I feel so totally dumb. Apparently the file was too large to attach, however I had another workbook from an older post that was still in the upload area. I was not paying attention. If you are not too frustrated with me would you mind one more look at the correct attachment?
    Attached Files Attached Files

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

    Re: VBA Code Run-time Error 13 - Type mismatch

    same deal-replace
    Please Login or Register  to view this content.
    by
    Please Login or Register  to view this content.
    and repeat for the other If statements

  10. #10
    Registered User
    Join Date
    08-17-2011
    Location
    Texas
    MS-Off Ver
    Excel 2010
    Posts
    14

    Re: VBA Code Run-time Error 13 - Type mismatch

    You are absolutely amazing!! Worked like a charm!!!

    Can you tell me why my statement was causing an error and what was different about yours?

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

    Re: VBA Code Run-time Error 13 - Type mismatch

    if you change more than one cell-for instance if you clear a range-then target.value is an array and you cannot compare an array to a string with an equality operator (the = operator)

+ 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. Run time error - type mismatch
    By justinng in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-10-2009, 11:24 PM
  2. Run-time Error '13': Type mismatch
    By siamadu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-13-2009, 09:58 AM
  3. Run-time error: Type mismatch
    By siamadu in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-11-2009, 03:12 PM
  4. type mismatch error in code
    By strikeofdawn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2008, 08:34 PM
  5. [SOLVED] Type Mismatch error in VBA code
    By bobby in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-10-2005, 04:10 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