Results 1 to 3 of 3

Match & Index code results in Runtime error 1004

Threaded View

  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:

    Private Sub Test()
    
    Dim t As String
    Dim TypeTable as Range
    Dim AccNo as Range
    
    t = Application.WorksheetFunction.Index(Sheets("ChartOfAccounts").Range("TypeTable"), Application.WorksheetFunction.Match(Left(Sheets("Journal").Range("C27").Value, 6), Sheets("ChartOfAccounts").Range("AccNo"), 0), 1)
    
    End Sub
    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:
    Private Sub Test()
    
    Dim t As String
    Dim TypeTable as Range
    Dim AccNo as Range
    
    t = Application.Index(Sheets("ChartOfAccounts").Range("TypeTable"), Application.Match(Left(Sheets("Journal").Range("C27").Value, 6), Sheets("ChartOfAccounts").Range("AccNo"), 0), 1)
    
    End Sub
    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.

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. 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