Results 1 to 6 of 6

[Solved] VBA Function not running

Threaded View

  1. #1
    Registered User
    Join Date
    08-18-2015
    Location
    Netherlands
    MS-Off Ver
    2010
    Posts
    10

    [Solved] VBA Function not running

    Hello all, I started using VBA about 2 days ago and have no prior programming experience. I was programming the Newton Raphson method, an iterative procedure, in order to calculate data for a chemical process. Whenever I hit the green Run button, nothing happens other than the Macros menu opening. If I hit F8 to do the code step by step, nothing happens as well. I'm obviously missing something obvious, could someone please help me out? I would greatly appreciate it

    Here is the code:

    Function Iteration(v As Double)
    
    Dim z1, z2, z3, z4, z5, k1, k2, k3, k4, k5, v, v_next, inum  As Double
    
    z1 = 0.43
    z2 = 0.42
    z3 = 0.079
    z4 = 0.001
    z5 = 0.07
    k1 = 1.75034457
    k2 = 0.28420735
    k3 = 0.07519503
    k4 = 0.02978122
    k5 = 5.3320266
    v = 0.5
    inum = 0
    
    Do
    v_next = v - f(v) / fdash(v)
    v = v_next
    inum = inum + 1
    
    Loop Until (inum = 100)
    
    
    End Function
    
    Function f(v As Double)
    
    f = (z1 * (k1 - 1) / (1 + v * (k1 - 1))) + (z2 * (k2 - 1) / (1 + v * (k2 - 1))) + (z3 * (k3 - 1) / (1 + v * (k3 - 1))) + (z4 * (k4 - 1) / (1 + v * (k4 - 1))) + (z5 * (k5 - 1) / (1 + v * (k5 - 1)))
    
    End Function
    
    Function fdash(v As Double)
    
    fdash = ((z1 * (k1 - 1) ^ 2) / (1 + v * (k1 - 1)) ^ 2) + ((z2 * (k2 - 1) ^ 2) / (1 + v * (k2 - 1)) ^ 2) + ((z3 * (k3 - 1) ^ 2) / (1 + v * (k3 - 1)) ^ 2) + ((z4 * (k4 - 1) ^ 2) / (1 + v * (k4 - 1)) ^ 2) + ((z5 * (k5 - 1) ^ 2) / (1 + v * (k5 - 1)) ^ 2)
    
    End Function
    Last edited by wassili; 08-19-2015 at 09:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to stop function running
    By Theodjinn in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 07-04-2017, 11:14 PM
  2. Excel 2007 : Running a macro using an if function
    By Sky188 in forum Excel General
    Replies: 3
    Last Post: 06-01-2012, 03:14 PM
  3. Stop Function From Running
    By realniceguy5000 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-13-2011, 05:04 PM
  4. Error running Match function in VBA
    By CrystalNewb in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-07-2009, 03:20 PM
  5. Running a function from another Workbook
    By ravinder_tigh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2009, 04:44 AM
  6. Recursive/Running Function
    By goldm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-07-2009, 08:34 AM
  7. Running Solver from Function
    By krepa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2006, 02:07 PM
  8. Syntax for running a macro from an =IF function?
    By BobH in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-01-2005, 09: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