+ Reply to Thread
Results 1 to 10 of 10

Runtime error 91 although object variable is set

  1. #1
    Guest
    Join Date
    05-09-2015
    Location
    Moon
    MS-Off Ver
    MS office 2013
    Posts
    24

    Runtime error 91 although object variable is set

    Hi!

    I'm experiencing some issues with my code which is suppose to retrive data from yahoo finance.

    Receives error code 91 object variable or with block variable not set and highlight row "If target.Row = rng.Row And target.Column = rng.Column Then".

    As I see it I have set target as range.

    Any ideas?

    Thanks in advance!



    Here is my code;

    Please Login or Register  to view this content.
    Last edited by JBeaucaire; 05-09-2015 at 11:14 AM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Runtime error 91 although object variable is set

    Above that line of code you have not yet "SET Target = ????" to anything.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Guest
    Join Date
    05-09-2015
    Location
    Moon
    MS-Off Ver
    MS office 2013
    Posts
    24

    Re: Runtime error 91 although object variable is set

    Thank you for suggestion. Any idea what I should set it equal to?

    Sort of a newbie

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Runtime error 91 although object variable is set

    No, only you know what the value A1 on sheet1 is being compared to, what is it?

  5. #5
    Guest
    Join Date
    05-09-2015
    Location
    Moon
    MS-Off Ver
    MS office 2013
    Posts
    24

    Re: Runtime error 91 although object variable is set

    It is suppose to be a stock ticker, for instance AAPL.

    The logic is that you are putting in a ticker and the macro go to yahoo finance to search for it.
    I have pretty much copied all from a youtube video, only difference is that he is using Sub Worksheet(ByVal target as range).

    ----Update----

    Here is the youtube link if anyone elese is interested https://youtu.be/PPaMZ-WN5So?t=574
    Last edited by Sinep D; 05-09-2015 at 01:36 PM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Runtime error 91 although object variable is set

    Yes, a worksheet_change macro is a self-targeted macro. It is triggered when a cell's value is physically changed by VBA or by hand. Once the value has changed, the macro is initiated and the "Target" is automatically defines as the "the cell that changed value".

  7. #7
    Guest
    Join Date
    05-09-2015
    Location
    Moon
    MS-Off Ver
    MS office 2013
    Posts
    24

    Re: Runtime error 91 although object variable is set

    Great thank you! Out of curiosity, which references do I need to turn on in order to copy the value from the website. Currently it is only searching for the ticker site without grabbing the ticker value.

    Used the ie.visible = true command to verify this and indeed it finds the ticker.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Runtime error 91 although object variable is set

    I apologize for not having time to further investigate your macro until tomorrow. In the meantime, here's a FUNCTION I know that works.

    Please Login or Register  to view this content.
    Install that into a standard code module (module1, module2, etc) and then you will have a new function available in your spreadsheet. Assuming you have GOOGL for instance in A1, then this formula in B1 would pull back that stock's price:

    =SHAREPRICE(A1)

  9. #9
    Guest
    Join Date
    05-09-2015
    Location
    Moon
    MS-Off Ver
    MS office 2013
    Posts
    24

    Re: Runtime error 91 although object variable is set

    Wow Awesome! Works like a charm, thank you sir!

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: Runtime error 91 although object variable is set

    Mr. JBeaucaire
    I tried your great UDF function but I got NAME error
    Any suggestion about that error
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

+ 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. An FYI: Runtime Error 91 (Object variable not set)
    By exceltabz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-18-2014, 09:25 AM
  2. Runtime Error 91 - object variable or with block variable not set
    By 0celj in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-23-2013, 09:40 PM
  3. runtime error 91 object variable or With block variable not set
    By tullemann in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2011, 01:27 PM
  4. Replies: 8
    Last Post: 02-17-2009, 02:24 PM
  5. Runtime error 91 - Object variable or with block variable not set
    By Christian411 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-04-2008, 08:05 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