Hello,
I need a VBA funcion that does the following:
Thanks for the help.![]()
Please Login or Register to view this content.
Hello,
I need a VBA funcion that does the following:
Thanks for the help.![]()
Please Login or Register to view this content.
Last edited by Pepe Le Mokko; 08-30-2019 at 11:06 AM.
This forum can be strict about rules (like putting code in code tags and giving descriptive thread titles). You will want to edit your post to include those code tags (see the forums FAQ link for instructions if you are unfamiliar) so that your topic does not get locked.
You might also provide a better description of what the code is doing/should be doing so we can better understand it. I see a lot of undefined/uninitialized variables in your code, which makes it difficult to understand exactly what you are doing. Some of what you have suggests to me that we will need to know what you know about arrays (and maybe other data types), so helping us understand what you know will help us help you.
Originally Posted by shg
Administrative Note:
Fallowing on MrShorty's comment:
Welcome to the forum.
We would very much like to help you with your query, however you need to include code tags around your code.
Please take a moment to add the tags. Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.
Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
As you are rather new here, I will do it for you this time. Have you read and understood our forum rules?
Sorry, I didnt't know that I had to use tags on code and I didn't understant what MrShorty meant by code tags
I'm still not sure what the code is trying to do. What I see the code doing is repeatedly evaluating the same expression at different values for ni.
IMO, this looks very similar to a previous thread (https://www.excelforum.com/excel-pro...in-angles.html ). It appears that you have rejected the lookup solution proposed in this thread without comment, and are pursuing what you have posted here.
Comparing the two threads, the overall problem looks to me like a root finding problem (https://en.wikipedia.org/wiki/Root-finding_algorithm ). You appear to be wanting to use an inefficient "brute force" algorithm for this. Are you required to use a brute force algorithm, or could you use a more efficient algorithm? Are you required to program your own root finding algorithm, or could you use something pre-programmed?
It appears that the expressions for Q are a little different between the two threads, but that should not impact the programmatic approach to the problem. Depending on how you answer the previous questions, I would approach the problem:
A) Using Excel's built in Solver/Goal Seek tools which are based on Newton's method. I generally prefer Solver over Goal Seek. I will add a reply to the other thread detailing how I would setup Solver.
B) Using spreadsheet formulas, implement my chosen root finding algorithm. I have a thread here that talks about implementing Newton's method in a spreadsheet: https://www.excelforum.com/tips-and-...ind-roots.html
C) Write a VBA UDF (like what you are trying to do here) that will use my chosen root finding algorithm to find the root. The last post in the other thread includes an example of a VBA UDF that implements Newton's method for a polynomial.
One key to implementing root finding algorithms in VBA (or similar programming language) is understanding loop structures. https://www.excelfunctions.net/vba-loops.html
Thank you for your help
Administrative Note:
Welcome to the forum.
We would very much like to help you with your query, however the thread title does not really convey what your request is about.
Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).
Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.
(Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks