+ Reply to Thread
Results 1 to 6 of 6

An innocent looking piece of code going wrong

  1. #1
    Forum Contributor
    Join Date
    11-02-2003
    Location
    Birmingham, UK
    MS-Off Ver
    Office 365
    Posts
    127

    An innocent looking piece of code going wrong

    I'm getting Application-defined or object defined error at this point in some code I'm working on. Is there anything obvious that I'm doing wrong here ?

    Range("Q2").Select
    ActiveCell.FormulaR1C1 = _
    "=VLOOKUP(E2,[C:\symtemp\TWOVRWold.xls]ProjMon'!E:P,12,FALSE)"
    Terry

    "... I thought I was a power user of Excel until I came onto these boards..."

  2. #2
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Try and replace [C:\symtemp\TWOVRWold.xls]ProjMon'!E:P with simply WorkBooks("TWOVRWold.xls").Sheets("ProjMon").Range("E:P"). Is there any reason to quote the full path?
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

  3. #3
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Try replacing ActiveCell.FormulaR1C1 with ActiveCell.Formula instead

  4. #4
    Forum Contributor
    Join Date
    11-02-2003
    Location
    Birmingham, UK
    MS-Off Ver
    Office 365
    Posts
    127
    The main reason as I understand for using the full path is that the TWOVRWold.xls will remain closed and not opened while the data is retrieved. So, Excel would need to know where the file is ???

    Maybe I'm wrong ?

  5. #5
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    There also seems to be a missing single ' in your code.

    "=VLOOKUP(E2,[C:\symtemp\TWOVRWold.xls]ProjMon'!E:P,12,FALSE)"

    Should this be

    "=VLOOKUP(E2,'[C:\symtemp\TWOVRWold.xls]ProjMon'!E:P,12,FALSE)"

    Matt

  6. #6
    Forum Contributor
    Join Date
    11-02-2003
    Location
    Birmingham, UK
    MS-Off Ver
    Office 365
    Posts
    127
    Yeeeeeeeeeeeeee Haaaaaaaaaawwwwwwwwwwww !

    You da king, Matt !

    Thanks for pointing this out, this now works a treat. Strange though, because that was a recorded macro in the first place. Unless, I accidentally deleted it somewhere along the line.

+ 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