Consulting

Results 1 to 3 of 3

Thread: Application-defined or object-defined error

  1. #1
    VBAX Regular
    Joined
    Mar 2008
    Posts
    16
    Location

    Application-defined or object-defined error

    Hi folks,
    I inherited a macro at work. It usually runs fine, but now breaks down.
    The error # and error msg box comes back as
    "1004 - Application-defined or object-defined error"

    I've only included the part where it breaks down since its so huge ...and I suspect its in the syntax or somethihng here.
    -------------------------------------------------------------------

    If CurrFile = "US" Then (it does = US)

    ActiveCell.Offset(0, 8).Formula = "=RtGet(""IDN"",A" & ActiveCell.Row & ",""OFFCL_CODE"")"

    ActiveCell.Offset(0, 7).Formula = "=VLOOKUP("" "" & RIGHT(I" & ActiveCell.Row & ",LEN(I" & ActiveCell.Row & ")-3),'c:\[Available.xls]Inventory'!$A:$T,4,FALSE)"
    this is where it breaksdown

    Else
    ActiveCell.Offset(0, 8).Value = 0

    -----------------------------------------------------------------
    Would love some help interpreting the "1004" error msg this generates.

    The size of the file this macro in and the file referenced (available.xls) have recently grown, they're both 10mb files now so I wonder if its a memory related issue as well.


    thanks much!!

  2. #2
    VBAX Regular
    Joined
    Mar 2008
    Posts
    16
    Location
    Had another thought on this: What this piece of code does (when it works) is drop a long vlookup formula in to a cell (then repeat for a bunch of rows).
    IS THERE A WAY to do the vlookup in vba and then put the resulting value in the excel cell - instead of doing the lookup in the excel cell itself.

    Something like application.formula.vlookup(blah blah blah).
    Does anyone know how to write vlookups IN vba???

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You coule do, but it would probably error in the same way. Have you checked the result of

    "" "" & RIGHT(I" & ActiveCell.Row & ",LEN(I" & ActiveCell.Row & ")-3)

    and see what it holds.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •