+ Reply to Thread
Results 1 to 8 of 8

Type Mismatch Error - When saving activeworkbook

Hybrid View

  1. #1
    Registered User
    Join Date
    02-25-2015
    Location
    Birmingham, England
    MS-Off Ver
    MS Office 2010
    Posts
    29

    Type Mismatch Error - When saving activeworkbook

    Hi guys,

    I am having an issue with saving an active workbook, I get "runtime error 13 type mismatch" when I step through the code. The weird thing is, the file actually saves in the location I want it to, but the code stops with that error message after saving.

    Dim start As Range
    Dim curmth As String
    Dim Depot As Integer
    
    curmth = Sheets("Lookups").Range("M29").Value                    'Cell M29 is a formulated cell which retrieves the month which is given in the filename
    
    i = 4
    
    Set start = Sheets("Main List").Range("A" & i)
    
    While start.Value <> ""
    
    Depot = start.Value
    
    If WorksheetFunction.CountIf(Sheets("Claims Summary").Range("A:A"), Depot) > 0 Then
            Sheets("Claims Summary").Copy
            ActiveWorkbook.SaveAs Filename:= _
            "[path]" & Depot & " - Claims Recharges - " & curmth & ".xlsx" _
            , FileFormat:=xlOpenXMLWorkbook, Password:="", WriteResPassword:="", _
            ReadOnlyRecommended:=False, CreateBackup:=False

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Type Mismatch Error - When saving activeworkbook

    In addition, short file names must not contain the following characters:

    plus sign (+)
    comma (,)
    semicolon (
    equals sign (=)
    left square bracket ([)
    right square bracket (])
    from MS Windows Dev Center
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    02-25-2015
    Location
    Birmingham, England
    MS-Off Ver
    MS Office 2010
    Posts
    29
    Quote Originally Posted by xladept View Post
    from MS Windows Dev Center
    Sorry I should have specified. The [path] was entered to save having to write out the full path of the file location. It does not have square brackets in. It's of the form "C:\abc\def\

  4. #4
    Valued Forum Contributor
    Join Date
    07-10-2017
    Location
    Toronto, Ontario
    MS-Off Ver
    Excel 2013
    Posts
    430

    Re: Type Mismatch Error - When saving activeworkbook

    Did you specify anywhere the location to save the file? Or this overwriting the previous file in the same location? Also, which line is causing the error?

  5. #5
    Registered User
    Join Date
    02-25-2015
    Location
    Birmingham, England
    MS-Off Ver
    MS Office 2010
    Posts
    29

    Re: Type Mismatch Error - When saving activeworkbook

    I'm not sure what you mean.

    The Filename is the the full extension of the path of where it should be saved. The error comes after pressing F8 on the ActiveWorkbook.SaveAs line.

    The weird thing is, the first file actually saves in the location but then I get the Type Mismatch error.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Type Mismatch Error - When saving activeworkbook

    Oh, I thought that if it only happened when you were stepping through that maybe Excel was outsmarting itself as is my wont

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Type Mismatch Error - When saving activeworkbook

    I've noticed that when you're stepping through and you have automatic calculation the program jumps to a function
    and you often get an error - if this is what's happening, try setting the book to manual calculation and try again -
    then if no problem - no problem

  8. #8
    Registered User
    Join Date
    10-12-2015
    Location
    Bristol, UK
    MS-Off Ver
    Office 365
    Posts
    39

    Re: Type Mismatch Error - When saving activeworkbook

    Just an observation, but
    Depot = start.Value
    will generate a Type 13 run-time error if start.Value is not castable to an integer.

    But then that's not the line where the error is being thrown, so that won't be the cause of this particular issue.

+ 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] RunTime Error 13 ( type mismatch ) error is comming TextboxAfter_Update
    By HaroonSid in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2017, 03:55 AM
  2. Conditional Formatting - Run Time Error '13' Type Mismatch Error
    By ksp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-17-2011, 07:37 PM
  3. Type mismatch while saving csv file
    By excel_vb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-24-2010, 05:38 PM
  4. type mismatch on saving excel calculation mode via VB app
    By Ken Shaffer in forum Excel General
    Replies: 3
    Last Post: 11-02-2005, 06:17 PM
  5. Help: Compile error: type mismatch: array or user defined type expected
    By lvcha.gouqizi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2005, 05:05 PM

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