+ Reply to Thread
Results 1 to 4 of 4

Mismatch error 13 breaking command button

  1. #1
    Forum Contributor
    Join Date
    06-09-2009
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    155

    Mismatch error 13 breaking command button

    OK not quite so dramatic but darn frustrating....

    On a numer of spreadsheets I get a "mismatch error 13" and as a result I am resigned to using two buttons for what should be a single function (and button) as the second function I want to run requires the first to be carried out first....

    The mismatch error does not stop the first function working, but does stop the code in its track and pops up the error mismatch message.

    I have tried ignore error commands but whilst they stop the pop up the code won't move on to the next string of code successfully. Has anybody had this type of error before and know which ignore error command will not only stop the pop up message being shown but also allow the two functions to run concurrently without stopping?

    Last edited by opsman; 06-13-2012 at 05:36 PM.

  2. #2
    Forum Contributor
    Join Date
    06-09-2009
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    155

    Re: Mismatch error 13 breaking command button

    If there's any takers on this, the error points at the "TestVal = TestCell.Value" line....

    Option Explicit

    Private Sub CommandButton1_Click()

    ' Sub ReplaceF()

    Dim RefRange As Range, _
    TestCell As Range, _
    LastGRow As Long, _
    TestColumn As Long, _
    TestVal As Long

    LastGRow = Cells(Rows.Count, "G").End(xlUp).Row
    Set RefRange = Range("G4:G" & LastGRow)

    'increment down refrange
    For Each TestCell In RefRange
    TestCell.Select
    If TestCell.Value = "" Then
    TestVal = 0
    Else
    TestVal = TestCell.Value
    End If

    'check: if col-f cell has same value quit
    If TestVal = Cells(TestCell.Row, "F").Value Then
    Exit Sub
    End If

    'if testval is greater than zero replace col-f val with g val.
    If TestVal <> 0 Then
    Cells(TestCell.Row, "B").Value = Cells(TestCell.Row, "C").Value
    Cells(TestCell.Row, "C").Value = Cells(TestCell.Row, "D").Value
    Cells(TestCell.Row, "D").Value = Cells(TestCell.Row, "E").Value
    Cells(TestCell.Row, "E").Value = Cells(TestCell.Row, "F").Value
    Cells(TestCell.Row, "F").Value = TestVal
    End If

    Next TestCell

    End Sub
    Last edited by opsman; 06-05-2012 at 04:27 PM.

  3. #3
    Forum Contributor
    Join Date
    06-09-2009
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    155

    Re: Mismatch error 13 breaking command button

    Just to save anybody the time posting about it, I have found a Microsoft hotfix for this named error..... alas no joy there though as it doesn't appear to work in this case!

  4. #4
    Forum Contributor
    Join Date
    06-09-2009
    Location
    Wales
    MS-Off Ver
    Excel 2003
    Posts
    155

    Re: Mismatch error 13 breaking command button

    Unfortunately didn't find the solution, but my needs have moved on and changing my approach to the coding made the error go away?! Going to mark this one as solved anyways.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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