+ Reply to Thread
Results 1 to 6 of 6

Run-time error '13' Type mismatch

  1. #1
    Registered User
    Join Date
    02-04-2010
    Location
    Phoenix
    MS-Off Ver
    Excel 2007
    Posts
    4

    Run-time error '13' Type mismatch

    Hi guys,

    I've got a spreadsheet that contains macros that remove columns and re-format the contents of a report. The idea is that the users copy the report (in xls format) and paste it in this workbook and run the macros by clicking on a button. My macros assume the first row contains the first record

    My users are not computer savvy and pasting the report in my spreadsheet by selecting any cell other than A1 will mean that my macros will pretty much butcher the report and the results will be useless. My solution was to unlock only cell A1 and protect the whole spreadsheet:

    Please Login or Register  to view this content.
    This way the users will not have other option but to select cell A1. My plan is that when they select A1 that would unprotect the worksheet so that they would be able to paste the report. This is the code I had in mind (notice I used the SelectionChange event; that may not be the best option but my knowledge on programming is limited):

    Please Login or Register  to view this content.
    The problem is that when I paste the report that immediately triggers the SelectionChange event and gives me an error message ("Run-time error '13': Type mismatch"). Anybody know what could be happening here?

    Thanks!

    A.
    Last edited by shg; 02-04-2010 at 06:36 PM. Reason: Add more code tags

  2. #2
    Forum Guru teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,364

    Re: Run-time error '13' Type mismatch

    Hi alepag,

    welcome to the forum. However, ...

    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

    I'll add the code tags for you this time, but please use them from now on.

  3. #3
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,677

    Re: Run-time error '13' Type mismatch

    Maybe like this:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    02-04-2010
    Location
    Phoenix
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Run-time error '13' Type mismatch

    I'm sorry Teylyn, that was a beginner's mistake...I'll go over the rules and make sure I follow them next time. Thanks for helping me with correcting my post!

    Shg, thanks for your reply. Unfortunately that didn't help; I'm getting the same error than I got before. As I said previously I'm not a "real" programmer so I could be dead wrong but, is it possible that I'm getting the error because the IF statement is checking if cell A1 is selected and I'm actually "selecting" the whole spreadsheet? (when I paste the report the whole spreadsheet is selected)

    Again, thank you to both of you for the help.

    Alejandro.

  5. #5
    Forum Guru shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,677

    Re: Run-time error '13' Type mismatch

    Yup, that would cause it to not work. Maybe like this:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-04-2010
    Location
    Phoenix
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Run-time error '13' Type mismatch

    EXCELLENT!! This code worked nicely!

    Thanks SHG, I really appreciate your help

    A.

+ 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