+ Reply to Thread
Results 1 to 7 of 7

Runtime Error 13 -Type mismatch error

Hybrid View

nikadon Runtime Error 13 -Type... 02-25-2013, 11:00 AM
Norie Re: Runtime Error 13 -Type... 02-25-2013, 11:05 AM
nikadon Re: Runtime Error 13 -Type... 02-25-2013, 11:35 AM
Norie Re: Runtime Error 13 -Type... 02-25-2013, 11:41 AM
nikadon Re: Runtime Error 13 -Type... 02-25-2013, 01:10 PM
Norie Re: Runtime Error 13 -Type... 02-25-2013, 01:19 PM
nikadon Re: Runtime Error 13 -Type... 02-25-2013, 01:37 PM
  1. #1
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Runtime Error 13 -Type mismatch error

    Hi,
    I have added a button that is suppose to select the data from another file and copy and paste in the selected month on the userform, but I am getting the error listed in the title "Runtime Error - Type mismatch error. I don't know if the that how to correct this error. It errors out at the area highlighted in red, this is where I name each sheet. I would type the name in B1 and the sheetname will change. The move sheet code I'll also include this work up to the point where the data must be paste on the new sheet base on the selection, then it won't paste and I receive the error. My deadline is by Thursday and I must test this week, please help


    Nika

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
        If Flag Then Exit Sub
        'Call FindNewLoans
       ' If Target = Worksheets(frmFindLoanInfo.cmbMnthClaim.Value) Then
        
        If Target = Range("B1") Then
            ActiveSheet.Name = Range("B1").Value
        End If
        
    End Sub
    
    Private Sub MoveSheets()
        Dim vFileNames As String
        vFileNames = ThisWorkbook.Name
    
        Application.ScreenUpdating = False
        Workbooks.Open Filename:="\\C:\Users\FHCCU\Documents\MicroLoanExtractCommission.xls"    'origin:= _
                                                                                                 xlWindows
        Range("a1:bp1").Select
        Range(Selection, Selection.End(xlDown)).Select
        Selection.Copy
        'Windows("Workbook1.xlsx").Activate
        Application.Wait Now + TimeValue("00:00:05")
        'Windows("MicroLoanExtractCommission").Activate
        'Sheets("Sheet1").Select
        'Sheets("MicroLoanExtractCommission").Select
    
        Workbooks(vFileNames).Activate
        Range("v6:ck6").Select
        'Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks _
         :=False, Transpose:=False
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
        Application.CutCopyMode = False
        'Sheets("Dec_2012").Copy Before:=Workbooks("MicroLoanTest.xlsm").Sheets(1)
    
        ActiveWorkbook.Save
    End Sub

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Runtime Error 13 -Type mismatch error

    What's in B1 of the active sheet when you get the error?

    Also, what is that code meant to do?

    Are you trying to compare what's in B1 with Target or are you trying to see if B1 is target?

    By the way, is this code connected to the userform?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Runtime Error 13 -Type mismatch error

    Hi
    B1 has the actual name of the sheet. The code names the sheet once it is typed in B1 in the active sheet. I have changed and is now trying to use userform where you would select the month and then it would perform the request. My problem is that when it is to go to the selected month I am getting the error. If I try to link it to the selection from the userform by using this line of code "' If Target = Worksheets(frmFindLoanInfo.cmbMnthClaim.Value) Then", then I get Runtime error 9 subscript out of range. I thought I should have connected it to the form.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Runtime Error 13 -Type mismatch error

    What exactly are you trying to do?

    Target is the range that's been changed on worsheet Sh.

    You can't compare it to a worksheet as this is doing.
    If Target = Worksheets(frmFindLoanInfo.cmbMnthClaim.Value) Then
    Also, unless frmFindLoanInfo.cmbMnthClaim.Value returns the name of a worksheet you'll get a subscript out of range error.

  5. #5
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Runtime Error 13 -Type mismatch error

    I don't know how to get past this hurdle, what am I suppose to do. I am going to include the section where the frmFindLoanInfo.cmbMnthClaim.Value is dealt with. Because once I try the copy process I am getting that message. I try to attach the file but it is too large. I have remove so of the buttons and included the Move Sheet function which is where the error is and zip and uploaded. Please have a look and see if you can help. Thanks

    Nika
    Private Sub UserForm_Initialize()
        Dim cmbMnClmSource As Range
    
        Set cmbMnClmSource = Worksheets("LoanOfficers").Range("A25:A36")
    
        txtDate.Value = Format(Date, "MMM-dd-yyyy")
    
        With cmbMnthClaim
            .List = cmbMnClmSource.Cells.Value
        End With
    
    End Sub
    Attached Files Attached Files

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Runtime Error 13 -Type mismatch error

    Nika

    I though the problem was in the code you posted in your first post?

  7. #7
    Registered User
    Join Date
    12-27-2012
    Location
    Kingston, Jamaica
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Runtime Error 13 -Type mismatch error

    I am not sure what I am doing that is wrong I want to be able to paste in the selected sheet after clicking on it in the userform. I do receive the error in what was posted before but I don't know what should be the fix, that is why I included the code for the form to see if that would shed some light. Sorry for the confusion.

+ 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