+ Reply to Thread
Results 1 to 4 of 4

Run-time Error '13' - Type mismatch

Hybrid View

  1. #1
    Registered User
    Join Date
    12-21-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    Run-time Error '13' - Type mismatch

    I have about 40K+ lines of "raw data" that I need to analyze. I am only interested in the lines that contain the word "Degraded". I have a macro that searches all lines of raw data and extracts any line containing the word "Degraded" (this macro also unlocks and locks the worksheet). The macro was working fine in the past; however, I am now getting a "Run-time Error '13' Type Mismatch" when I run the macro. It seems to get hung up on the string
    "If InStr(v, "Degraded.") > 0 Then"
    This is probably because the word "Degraded" is not an integer.
    Does anyone know a better way to do this, or other work-arounds.

    The full macro is posted below:

    Sub Luxation2()
        Dim K As Long, r As Range, v As Variant
        K = 1
        Dim w1 As Worksheet, w2 As Worksheet
        Set w1 = Sheets("All Msg")
        Set w2 = Sheets("Degraded Msg")
        w1.Activate
        w2.Unprotect Password:=""
        For Each r In Intersect(Range("A:A"), ActiveSheet.UsedRange)
            v = r.Value
        If InStr(v, "Degraded.") > 0 Then
                r.Copy w2.Cells(K, 1)
                K = K + 1
            End If
        Next r
        w2.Protect Password:=""
    End Sub
    Last edited by elmowax; 12-21-2014 at 05:33 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,731

    Re: Run-time Error '13' - Type mismatch

    You might have Error value in variable v.
    try
    If Not IsError(v) Then
        If InStr(v, "Degraded.") > 0 Then
        ......
        End If
    End If
    However, it can be done with AutoFilter I guess....

  3. #3
    Registered User
    Join Date
    12-21-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    2

    Re: Run-time Error '13' - Type mismatch

    Thank you jindon. The macro seems to be working now. I'm not sure how your fix works, but It does. I'll have to study a little more about it. Thanks!!!!!!!!!!!!!!!

    The new working macro is
    Sub Luxation2()
        Dim K As Long, r As Range, v As Variant
        K = 1
        Dim w1 As Worksheet, w2 As Worksheet
        Set w1 = Sheets("All Msg")
        Set w2 = Sheets("Degraded Msg")
        w1.Activate
        w2.Unprotect Password:=""
        For Each r In Intersect(Range("A:A"), ActiveSheet.UsedRange)
            v = r.Value
            If Not IsError(v) Then
            If InStr(v, "Degraded.") > 0 Then
                r.Copy w2.Cells(K, 1)
                K = K + 1
            End If
            End If
        Next r
        w2.Protect Password:=""
    End Sub

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,731

    Re: Run-time Error '13' - Type mismatch

    If that takes care of your original question, select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] Run-time error '13': Type mismatch
    By Aeneren in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-26-2014, 01:52 PM
  2. Run-Time Error '13: Type Mismatch
    By mlegge77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2013, 04:44 PM
  3. Run-time error '13' Type mismatch
    By caierhui in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-14-2012, 03:20 AM
  4. Run Time Error '13'. Type Mismatch
    By TonyforVBA in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-08-2010, 09:29 AM
  5. Run time error: Type mismatch
    By Johannekie in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-04-2008, 09:11 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