+ Reply to Thread
Results 1 to 5 of 5

Type Mismatch Error in VBA

  1. #1
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Type Mismatch Error in VBA

    I made a macro that would copy data from two vertical collumns into a more organized table. However, the program keeps outputting a type mismatch error. The funny thing about this error is that its marking my declaration of "sub preformat" as the error. When I attempt to put breakpoints the code never advances beyond this first line. What is the problem? (When I revert back to an earlier version of the code, the problem does not exist, but as soon as I paste the remaining code, I get an error). I am absolutely baffled.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Type Mismatch Error in VBA

    The easy and best way to trouble shoot this problem is to;

    1. at the point of the error dialog, click on debug.
    2. the highlighted code will need to be examined for values and operations.
    3. with the type mismatch errors, the value of data(from cells) matters.


    You have options for fixing this.
    1. Fix it yourself.
    2. Have me fix it for you(post the workbook).
    3. Setup a remote session(with Join.Me) and a phone call to show you the steps required for trouble shooting this problem.

    My advice to you is:
    Learn how to use the debugger.

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Type Mismatch Error in VBA

    A few problems

    This line is nonsense

    For N = 1 To 14 Then

    the Then is superfluously wrong.

    Then you try to use an array currRow2 as the row number in a range, which makes no sense, but you also store 2 in every element of that array, so why bot just use 2?

  4. #4
    Registered User
    Join Date
    02-06-2012
    Location
    NYC, US
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Type Mismatch Error in VBA

    @ Dennis I did click on debug and the funny thing is that the error is "Sub preformat()", which makes absolutely no sense.

    @ Bob Phillips Because I need to increment each row for the table on the following sheet. Each collumn has a corresponding row..But using currRow2 as the row number in a range was the error. I changed it so that an index is included and now it works, thanks.
    Last edited by juliorevka; 04-20-2012 at 12:29 PM.

  5. #5
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Type Mismatch Error in VBA

    I think I see what you intend, this should fix it

    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