+ Reply to Thread
Results 1 to 12 of 12

Vlookup to external workbook giving runtime or syntax error.

  1. #1
    Registered User
    Join Date
    07-21-2019
    Location
    USA
    MS-Off Ver
    office 365 pro Excel version 1906
    Posts
    19

    Vlookup to external workbook giving runtime or syntax error.

    Hello

    I am brand new to VBA and am trying to automate some reports I make. I use many vlookups but have run into difficulty with a vlookup on an external book.

    I have opened the external book and I have tested it using my normal vlookup in the worksheet, and works no problem

    here is the code i am using, and excuse the crudeness as I am still new to VBA and scripting in general

    Please Login or Register  to view this content.
    I have tried so many different things, but will get various runtime errors and or syntax errors.

    Any advice on the vlookup is greatly appreciated.

    thanks

    Damn Groundhog

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Vlookup to external workbook giving runtime or syntax error.

    Welcome to the forum!

    Is the error on the comment.Value line? It was earlier assigned a string value. Since it is not an object, it will have no Value property.

  3. #3
    Registered User
    Join Date
    07-21-2019
    Location
    USA
    MS-Off Ver
    office 365 pro Excel version 1906
    Posts
    19

    Re: Vlookup to external workbook giving runtime or syntax error.

    Precisely

    on the comments.value line i am getting a runtime 1004 error, Unable to get the vlookup property of the worksheet function class.

    I don't know if i have a wrong variable declared or have written the vlookup function incorrect

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vlookup to external workbook giving runtime or syntax error.

    If I understand correctly what you're trying to achieve.
    Please Login or Register  to view this content.
    Last edited by bakerman2; 07-21-2019 at 08:54 PM. Reason: Edited starting cell for loop
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Vlookup to external workbook giving runtime or syntax error.

    Try replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-21-2019
    Location
    USA
    MS-Off Ver
    office 365 pro Excel version 1906
    Posts
    19

    Re: Vlookup to external workbook giving runtime or syntax error.

    bakerman2

    thank you that seemed to have worked for me. I am now trying to figure out exactly why it worked and why I need to use Range for this.

    Appreciate all the help

    Damn GroundHog

  7. #7
    Registered User
    Join Date
    07-21-2019
    Location
    USA
    MS-Off Ver
    office 365 pro Excel version 1906
    Posts
    19

    Re: Vlookup to external workbook giving runtime or syntax error.

    Uh oh

    So, I did some testing out, and moved the other workbook data locally and that is how it worked.

    However

    when i tried to use the external source, i was returned with a #value instead of the data.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vlookup to external workbook giving runtime or syntax error.

    Let's try this then.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    07-21-2019
    Location
    USA
    MS-Off Ver
    office 365 pro Excel version 1906
    Posts
    19

    Re: Vlookup to external workbook giving runtime or syntax error.

    Thanks

    I have tried this and now I am getting a

    Runtime error 1004

    There is an error in the formula you entered.

    I will search this function out more and see where it has gone wrong.

    Groundhog

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vlookup to external workbook giving runtime or syntax error.

    Tested it myself and there's nothing wrong with the function at all.

    More likely there's something wrong with the sheetnames or something similar.

  11. #11
    Registered User
    Join Date
    07-21-2019
    Location
    USA
    MS-Off Ver
    office 365 pro Excel version 1906
    Posts
    19

    Re: Vlookup to external workbook giving runtime or syntax error.

    Ok.

    After my bout of stupidity, it does indeed work.

    I can't begin to thank you for this.

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Vlookup to external workbook giving runtime or syntax error.

    You're welcome and thanks for rep+.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. Macros giving Runtime Error when used on Mac computer
    By bwaldon4 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-11-2019, 11:48 PM
  2. [SOLVED] macro copy and paste giving runtime error
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-22-2017, 11:45 AM
  3. Dir() Giving Runtime Error If Anything But Parent Directory Specified
    By TankBuilder88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-05-2014, 04:15 PM
  4. [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
  5. [SOLVED] Macro giving runtime error on one PC and not another
    By Ingrid in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2005, 03:05 PM
  6. [SOLVED] RE: Macro giving runtime error on one PC and not another
    By Jim Thomlinson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-13-2005, 01:05 PM
  7. [SOLVED] Excel help giving runtime error
    By Hari Prasadh in forum Excel General
    Replies: 2
    Last Post: 01-24-2005, 05:06 AM

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