+ Reply to Thread
Results 1 to 4 of 4

Run-time error '13' Type mismatch; drag and copy

  1. #1
    Registered User
    Join Date
    12-26-2012
    Location
    Las Vegas
    MS-Off Ver
    Excel 2010
    Posts
    2

    Run-time error '13' Type mismatch; drag and copy

    I am new to VBA and have run into an error that I am hoping someone can provide some help.
    Below is the code I am running to insert a static date into column B when a "x" is entered into column A. The code works fine as long as I only enter 1 "X" at a time but if I try to drag and copy down column A I get the 'run-time error 13 Type mismatch' on the third line of code: "If Target.Value = "X" Then"
    Why will it not let me drag and copy down column A?

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A5:A500")) Is Nothing Then Exit Sub
    If Target.Value = "X" Then
    Application.EnableEvents = False
    Target.Offset(0, 1) = Now
    Application.EnableEvents = True
    End If
    End Sub

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Run-time error '13' Type mismatch; drag and copy

    Hi, it seems that TARGET is defined as Range and cannot take strings... A member of target can take strings

  3. #3
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Run-time error '13' Type mismatch; drag and copy

    It's a problem with trying to evaluate the contents of a multi-cell range in one statement, I'd imagine. Try:

    Please Login or Register  to view this content.
    Oh, and can you read the forum rules and use code tags when you post, please?

  4. #4
    Registered User
    Join Date
    12-26-2012
    Location
    Las Vegas
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Run-time error '13' Type mismatch; drag and copy

    Thank you Andrew-R for the response, your suggestion corrected the error. This is my first posts and I have since read the forum rules and will use code tags on future posts. Thanks again,

+ 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