+ Reply to Thread
Results 1 to 18 of 18

When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

  1. #1
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Thumbs up When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Hello everyone!!

    I need your help. I've written UDF called GetRate, which gets the exchange rates from the site of National Bank, based on Currency Name and Date. This function works well when I apply this to one cell, but when I try to apply this function to the multiple cells at once, it returns sometimes "0" for some cells. I can not solve this problem by myself, therefor I need your help dear Excel Gurus.

    Here is the code of GetRate function:

    Please Login or Register  to view this content.

    Excel file whith UDF is in below attached file:

    GetRate.xlsm



    http://www.mrexcel.com/forum/excel-q...-0-result.html
    Last edited by orkhan.gasimli; 08-22-2013 at 01:18 AM.

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Hi, I tried changing the formula for one of the 0's, for example cell C11, to " =GetRate(B11,A11) ", and it's working fine.

  3. #3
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    You are right. When I do this manually for each cell with 0 result, it works. But this is annoying when you have thousand of cells

  4. #4
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Please guys! I need your help!

  5. #5
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!


  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    Remember what the dormouse said
    Feed your head

  7. #7
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    No one wants to solve my problem, that is why I've posted in other forum.

  8. #8
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!


  9. #9
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Please somebody help!

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

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    I can't solve this problem, but I can shed some light on what is happening and why it fails when applied enmasse.

    Most UDFs operate within Excel's own memory, even very long complex calculations carried out very quickly in memory and the results fed back to the cell.

    Your UDF does not operate that way, it actually creates a connection to an external document type, fills that document, then extract a piece of information from that document, then feeds that back to the cell before destroying the object it created.

    That's fine for a one-off, but when you have Excel trigger a bunch of those at the same time, it just gets lost in the resource overload. Many of the the cells simply fail as a result, while you can come back to those cells later and reapply the formula and it works fine, because once again it's a one-off.

    So, you're going to have to live with this behavior if you're applying this particular UDF to lots of cells, it's the nature of that beast.
    _________________
    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!)

  11. #11
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Quote Originally Posted by JBeaucaire View Post
    I can't solve this problem, but I can shed some light on what is happening and why it fails when applied enmasse.

    Most UDFs operate within Excel's own memory, even very long complex calculations carried out very quickly in memory and the results fed back to the cell.

    Your UDF does not operate that way, it actually creates a connection to an external document type, fills that document, then extract a piece of information from that document, then feeds that back to the cell before destroying the object it created.

    That's fine for a one-off, but when you have Excel trigger a bunch of those at the same time, it just gets lost in the resource overload. Many of the the cells simply fail as a result, while you can come back to those cells later and reapply the formula and it works fine, because once again it's a one-off.

    So, you're going to have to live with this behavior if you're applying this particular UDF to lots of cells, it's the nature of that beast.
    Thank you a lot! This is very helpfull comment and I try to apply this approach. I hope I will be able to fix this problem. Thanks again!

  12. #12
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Quote Originally Posted by JBeaucaire View Post
    I can't solve this problem, but I can shed some light on what is happening and why it fails when applied enmasse.

    Most UDFs operate within Excel's own memory, even very long complex calculations carried out very quickly in memory and the results fed back to the cell.

    Your UDF does not operate that way, it actually creates a connection to an external document type, fills that document, then extract a piece of information from that document, then feeds that back to the cell before destroying the object it created.

    That's fine for a one-off, but when you have Excel trigger a bunch of those at the same time, it just gets lost in the resource overload. Many of the the cells simply fail as a result, while you can come back to those cells later and reapply the formula and it works fine, because once again it's a one-off.

    So, you're going to have to live with this behavior if you're applying this particular UDF to lots of cells, it's the nature of that beast.
    I want to mention one more point. I have created my function based on the similar function which extracts the data from the site of Russian Central Bank. This function works well also when applied enmasse. Here is the code of this function:

    Please Login or Register  to view this content.

  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    If I were to put money on it, I'd say that the website limits the amount of requests in a given time period either to prevent DoS attacks or to prevent this type of automated scraping in vast quantities. My advice would be to write a loop to pull all the data in a macro, check the results and if the expected results aren't found then pause the macro for a second or two before continuing

  14. #14
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Quote Originally Posted by Kyle123 View Post
    If I were to put money on it, I'd say that the website limits the amount of requests in a given time period either to prevent DoS attacks or to prevent this type of automated scraping in vast quantities. My advice would be to write a loop to pull all the data in a macro, check the results and if the expected results aren't found then pause the macro for a second or two before continuing
    Thank you for your advice. I've tried to do so, but I'm doing something wrong. Could you please help me?

  15. #15
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Please heeelp!!!

  16. #16
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,612

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Have you considered DoEvents or Application.Wait before/after the load?
    Ben Van Johnson

  17. #17
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Quote Originally Posted by protonLeah View Post
    Have you considered DoEvents or Application.Wait before/after the load?
    Please Login or Register  to view this content.
    I've rewritten my code in this way, but I'm still getting zeros. Am I missing something?
    Last edited by JBeaucaire; 08-26-2013 at 05:15 PM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  18. #18
    Registered User
    Join Date
    05-17-2013
    Location
    Германия
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: [B]When applying GetRate UDF to multiple cells at once some cells becomes "0" result!!

    Noone wants to help mee

+ 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. Change "Parent" cell based on results of multiple "Children" cells
    By ccowman in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 12-14-2012, 02:33 AM
  2. applying diagonal borders to cells with the value "x"
    By skr345 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-18-2011, 12:17 AM
  3. Applying condition "IF" to a range of cells....
    By lolcatz in forum Excel General
    Replies: 4
    Last Post: 04-14-2010, 03:19 AM
  4. Replies: 2
    Last Post: 08-21-2008, 06:08 AM
  5. Copy range of cells omitting formulas that result in " "
    By Plot only cells with values in column in forum Excel General
    Replies: 1
    Last Post: 05-24-2005, 04:06 PM

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