+ Reply to Thread
Results 1 to 5 of 5

Run-time error: Type mismatch

  1. #1
    Registered User
    Join Date
    02-11-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Run-time error: Type mismatch

    I am new to learn how to program with VBA and Excel. This code came from a book that I borrowed from the library. When I run the code, I keep get the error message: Run-time error '13': Type mismatch. I can not figure out why because I have gotten a grasp of the VBA syntax. I have also attached the sample file that the book came with in order to use the code. Thank you for all your help in advance.



    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by VBA Noob; 02-11-2009 at 03:16 PM.

  2. #2
    Forum Expert
    Join Date
    01-12-2007
    Location
    New Jersey
    Posts
    2,127

    Re: Run-time error: Type mismatch

    First, as per forum rules, please wrap any VBA code. The moderators frown upon any code not being wrapped.

    The reason you have a Type Mismatch Error is because of this line:

    Please Login or Register  to view this content.
    This line refers to Range("total"). You cant add a value to a range. What exactly are you trying to do? Do you want to take a sum of the the second column in the totals named range?

    If so, amend the line to something like the below:

    Please Login or Register  to view this content.
    Let us know if that helps.

  3. #3
    Registered User
    Join Date
    02-11-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Run-time error: Type mismatch

    Thanks for your reply. How do I ensure that the VBA code is wrapped? Please advise.

    The book states that:

    The purpose of this code is to enable the user to enter a new Rep Name using the textbox(variable is called RepBox), along with the sales for the Rep through the Starting Sales textbox. There is alos a listbox included so that the user can check to see that they do not duplicate the entry of a Rep Name.

    When looking at the image and the Excel file that I attached(see worksheet "weeklysales") that references the code, after the Rep Name is entered and four sales amounts are inputted the SalesBox, there should be a new line added just before the Total row.

    I have checked the source code to see if I had a typo, but it is exactly how it is in the book.

    The author explains later in another passage that the "total" is an object. I am confused.

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988

    Re: Run-time error: Type mismatch

    siamadu,

    Please read the below and then edit you're first post to include code tags as per forum rules

    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

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  5. #5
    Registered User
    Join Date
    02-11-2009
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    93

    Re: Run-time error: Type mismatch

    Is my code formatted the according the forum rule #3?
    Can you also open my Excel attachement I posted with my original posting?


    Please Login or Register  to view this content.

+ 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