+ Reply to Thread
Results 1 to 3 of 3

VB error, runtime error 13 (type mismatch)

  1. #1
    Registered User
    Join Date
    11-07-2005
    Location
    Canada
    Posts
    3

    VB error, runtime error 13 (type mismatch)

    I don't know why the following code keeps coming back as a runtime error 13, type mismatch; I have checked the code several times and I can't find the problem - can anyone help me?

    Option Explicit
    Sub cmdclick()

    Dim app As Application
    Dim wkbk As Workbook
    Dim shtctrl As Worksheet

    Dim StarName As String

    Set wkbk = ThisWorkbook
    Set app = wkbk.Application
    app.ScreenUpdating = False
    Set wkbk = ThisWorkbook
    Set shtctrl = wkbk.Worksheets("Control")

    StarName = wkbk.Path & "\" & "STAR Week No " & _
    wkbk.Names("WeekNo").RefersToRange.Value & " " & _
    Format(wkbk.Names("ControlDate").RefersToRange.Value, "mmm dd yy")

    MakeSTAR StarName

    MsgBox "Finished"

    End Sub

  2. #2
    paul.robinson@it-tallaght.ie
    Guest

    Re: VB error, runtime error 13 (type mismatch)

    Hi
    The line
    Set app = wkbk.Application

    is your problem. You can have Application.wkbk, but not the other way
    round. You also have _ when you need (space)_. I didn't check the two
    lines after StarName is defined.

    Try this:
    Option Explicit
    Sub cmdclick()


    Dim wkbk As Workbook
    Dim shtctrl As Worksheet

    Dim StarName As String
    Application.ScreenUpdating = False

    Set wkbk = ThisWorkbook
    Set shtctrl = wkbk.Worksheets("Control")

    StarName = wkbk.Path & "\" & "STAR Week No " & _
    wkbk.Names("WeekNo").RefersToRange.Value & " " & _
    FORMAT(WKBK.NAMES(\"CONTROLDATE\").REFERSTORANGE.VALUE, \"MMM DD YY\")

    MakeSTAR StarName

    MsgBox "Finished"

    End Sub

    regards
    Paul
    hindlehey wrote:
    > I don't know why the following code keeps coming back as a runtime error
    > 13, type mismatch; I have checked the code several times and I can't
    > find the problem - can anyone help me?
    >



  3. #3
    Registered User
    Join Date
    11-07-2005
    Location
    Canada
    Posts
    3

    Thanks

    Thanks so much, this did help!

+ 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