+ Reply to Thread
Results 1 to 3 of 3

Match & Index code results in Runtime error 1004

  1. #1
    Registered User
    Join Date
    09-06-2012
    Location
    Alberton, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    30

    Match & Index code results in Runtime error 1004

    Hi All

    I am trying to write the vba code for the Match & Index functions. My code results in a Runtime Error 1004: Application defined or object defined error.

    My code is:

    Please Login or Register  to view this content.
    I have tested the "Left(Sheets("Journal").Range("C27").Value, 6)" and the "Index" portion of the code with no errors. The error occurs on the "Match" portion of the code.

    The variables "TypeTable" and "AccNo" are Named Ranges on the "ChartOfAccounts" worksheet.

    I would appreciate it if anyone could please tell me what I am doing wrong.

    I have subequently changed the code by removing "WorksheetFunction" - see new code below:
    Please Login or Register  to view this content.
    This has resolved the Runtime Error 1004, but now I have an Error 13 Type Mismatch error.

    Any suggestions will be highly appreciated.

    Thank you
    Last edited by DJvdW; 09-26-2013 at 08:39 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Match & Index code results in Runtime error 1004

    It is difficult to diagnose this just by looking at your code. I don't see any obvious errors. Can you attach your file?

    First, I would generally suggest going back to Application.WorksheetFunction. Application.Match does not seem to be documented and though I got it to work, I don't know what's the difference between using that vs. Application.WorksheetFunction.Match. It may not be causing your problem but I would minimize the number of variables here.

    One strategy for debugging this kind of thing is to break the operation into multiple steps so you can see exactly what step is failing. For example, step through this code in the debugger and look at the results at every step:
    Please Login or Register  to view this content.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    09-06-2012
    Location
    Alberton, South Africa
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Match & Index code results in Runtime error 1004

    Hi Jeff

    I tried your code, and it resulted in the same errors. After another search on the internet, I came up with a solution that worked. I changed "L" to "CLng(L)" in the Match function line.

    I have also made 2 other changes (refer the Dim and Set R2 lines)

    Here is the final code:

    Please Login or Register  to view this content.
    Thank you for your help.

+ 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 1004' when trying to Rename Worksheet using vba code
    By Raporter65 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-28-2013, 07:43 PM
  2. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  3. Macro to copy contents of one page to another results in runtime error 1004
    By RyanAkers in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-23-2010, 07:40 PM
  4. Runtime Error Code 1004
    By laks in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-19-2007, 07:08 PM
  5. [SOLVED] Series Collection Results in Runtime Error 1004
    By Matthew Cunliffe in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-25-2006, 06:40 PM

Tags for this Thread

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