+ Reply to Thread
Results 1 to 12 of 12

runtime error 13 type mismatch

Hybrid View

chappie runtime error 13 type mismatch 01-30-2009, 08:22 AM
royUK Re: runtime error 13 type... 01-30-2009, 08:28 AM
royUK Re: runtime error 13 type... 01-30-2009, 08:30 AM
chappie Re: runtime error 13 type... 01-30-2009, 08:34 AM
chappie Re: runtime error 13 type... 01-30-2009, 08:43 AM
chappie Re: runtime error 13 type... 01-30-2009, 09:17 AM
royUK Re: runtime error 13 type... 01-30-2009, 09:25 AM
chappie Re: runtime error 13 type... 01-30-2009, 09:30 AM
royUK Re: runtime error 13 type... 01-30-2009, 09:34 AM
chappie Re: runtime error 13 type... 01-30-2009, 09:38 AM
dp1 Re: runtime error 13 type... 08-30-2012, 09:56 PM
Cutter Re: runtime error 13 type... 08-30-2012, 10:12 PM
  1. #1
    Registered User
    Join Date
    01-30-2009
    Location
    Zwolle, the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    6

    runtime error 13 type mismatch

    Hi,

    I seem to have some type mismatch in my macro...
    The error appears every time i insert or delete a row in the worksheet.

    This is the code:
    Private Sub TextBox1_Change()
    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Address = "$B$25" And Target.Value <> "" Then
    Sheets("brief").Range("b15").Value = Now
    End If
    End Sub

    Error is in the line: If Target.Address = "$B$25" And Target.Value <> "" Then

    Anyone with a suggestion?
    Last edited by royUK; 01-30-2009 at 08:28 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: runtime error 13 type mismatch

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    As this is your first post I will add them, but you must read the forum rules before posting again.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: runtime error 13 type mismatch

    You need to delete this lines,
    Private Sub TextBox1_Change()

  4. #4
    Registered User
    Join Date
    01-30-2009
    Location
    Zwolle, the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: runtime error 13 type mismatch

    That doesn't seem to make any difference.

    As it is still pointing out the mismatch in:

    If Target.Address = "$B$25" And Target.Value <> "" Then

  5. #5
    Registered User
    Join Date
    01-30-2009
    Location
    Zwolle, the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: runtime error 13 type mismatch

    ... Funny thing is, the error only appears when I insert of delete a row....

  6. #6
    Registered User
    Join Date
    01-30-2009
    Location
    Zwolle, the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: runtime error 13 type mismatch

    yeahaaa

    found a solution...
    just cut the errors by disabling the errors like this:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    
    On Error Resume Next
    
        If Target.Address = "$B$25" And Target.Value <> "" Then
            Sheets("brief").Range("b15").Value = Now
        End If
        
    On Error GoTo 0
    
    End Sub
    cheerio!

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: runtime error 13 type mismatch

    That's not a solution, that's ignoring the errors.

  8. #8
    Registered User
    Join Date
    01-30-2009
    Location
    Zwolle, the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: runtime error 13 type mismatch

    Sorry true.. therefore found another REAL solution:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    If Target.Count = 1 Then
    If Target.Address = "$B$25" And Target.Value <> "" Then
    Sheets("brief").Range("b15").Value = Now
    End If
    End If
    End Sub
    Added the code:
    If Target.Count = 1 Then
    Because Target.Value is targeted at one cell.
    This code prevents that.

    Cheerio!

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: runtime error 13 type mismatch

    That's better, you must have been selecting several cells.

  10. #10
    Registered User
    Join Date
    01-30-2009
    Location
    Zwolle, the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: runtime error 13 type mismatch

    Yep that's it, when selecting a row on the left side you automatically select multiple cells (all cells horizontal on that row).

    So this solution helps indeed.

    Thanks for your replies.

  11. #11
    Registered User
    Join Date
    08-30-2012
    Location
    Chandler, AZ
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: runtime error 13 type mismatch

    Hi, i get the same runtime error in my VBA macro. My code is below. now the funny thing is if I delete "StartInsTime" my code runs, but if I include it i get the runtime error. Any clues on how to resolve this?

    With ActiveSheet.QueryTables.Add(Connection:=Array( _
            "OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=Mscan100_db;Data Source=IntelDb2\MSSQL20" _
            , _
            "08;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=INTELDB2;Use Encryption for Data=False;Tag wi" _
            , "th column collation when possible=False"), Destination:=Range("A1"))
            .CommandType = xlCmdSql
            '.CommandText = Array(sel_clause & frm_clause & whe_clause)
                  
            .CommandText = Array( _
            "SELECT DISTINCT " & "LotSn" & "," & "Orientation" & "," & "PanelSn" & "," & IP & "." & IPI & "," & "StartInspTime" & "FROM InspPasses Inner Join " & IPS & " ON InspPassSubstrates.InspPassID = InspPasses.InspPassID  Inner Join" & Chr(10) & "     InspRunSubstrates ON InspRunSubstrates.InspRunSubstID = InspPas" _
            , _
            "sSubstrates.InspRunSubstID  Inner Join" & Chr(10) & "     InspPassDefects ON ((InspPassDefects.hlp_SubstID = InspRunSubstrates.SubstID) AND (InspPassDefects.hlp_InspPassID = InspPasses.InspPassID))  Inner Join" & Chr(10) & "     BT_DefectResultCode ON BT_Def" _
            , _
            "ectResultCode.DefectResultCodeID = InspPassDefects.DefectResultCodeID Inner Join" & Chr(10) & "     InspRuns ON InspRuns.InspRunID = InspPasses.InspRunID  Inner Join" & Chr(10) & "     BT_InspRuns ON BT_InspRuns.BT_InspRunID = InspRuns.BT_InspRunID  Inner Jo" _
            , _
            "in" & Chr(10) & "     BT_Products ON BT_Products.ProdID = BT_InspRuns.ProdID  Inner Join" & Chr(10) & "     BT_DieCoordinates ON ((BT_DieCoordinates.DieNr = InspPassDefects.hlp_DieNr) AND (BT_DieCoordinates.SubstTypeID = BT_Products.SubstTypeID))     " & Chr(10) & " Where" _
            , " InspPasses.InspPassID in ('8135')")
            
            
            .Name = "INTELDB2_MSSQL2008 Mscan100_db"
            .FieldNames = True
            .RowNumbers = False
            .FillAdjacentFormulas = False
            .PreserveFormatting = True
            .RefreshOnFileOpen = False
            .BackgroundQuery = True
            .RefreshStyle = xlInsertDeleteCells
            .SavePassword = False
            .SaveData = True
            .AdjustColumnWidth = True
            .RefreshPeriod = 0
            .PreserveColumnInfo = True
            .SourceConnectionFile = _
            "C:\Documents and Settings\Valued Customer\My Documents\My Data Sources\INTELDB2_MSSQL2008 Mscan100_db.odc"
            .Refresh BackgroundQuery:=False
        End With
        End Sub
    Last edited by dp1; 08-30-2012 at 09:58 PM. Reason: tags

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: runtime error 13 type mismatch

    Hello dp1, and welcome to the forum.

    Unfortunately you have inadvertently broken one of the forum rules. Please read the following and make the necessary change. Thanks.

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

+ 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