Results 1 to 10 of 10

Finding solution by narrowing down

Threaded View

  1. #1
    Registered User
    Join Date
    12-20-2010
    Location
    the Netherlands
    MS-Off Ver
    Excel 2003
    Posts
    5

    Post Finding solution by narrowing down

    Hi guys,

    I am new to this forum and obviously have an Excel VBA question:

    I have a macro that finds an optimal solution in K14 while N55 must be 0, apart from some other constraints. The method I currently use consists of starting with entering 0 in K14, check whether N55 is 0, and if not, entering 0.5 in K14, check whether N55 is zero, and if not, entering 1.0 in K14, etc. etc. Excel will find the solution, but it takes a lot of time.

    The macro looks like this:

    Sub SOLVE()
    Dim i As Double
    
    Application.Run "Conversie"
    Application.Run "BBV_max"
    Application.Run "BBV_max_A12"
    
    For i = 0 To 1000 Step 0.5
        Worksheets("COCKPIT").Range("K14") = i
        Application.Run "Conversie"
        If CLng(Worksheets("COCKPIT").Range("N55")) = 0 Then Exit For
    Next i
    
    End Sub
    I was wondering whether there would be a faster method of obtaining my desired result. For example, if I know that the value must lie between 0 and 1000, could I use a macro the narrows down to the solution, instead of trial and error starting from 0?
    If so, could you help me with such code? Or perhaps, such code is already available?

    Please let me know if I do not comply with certain forum rules, as I do intent to.

    Thanks for your help!
    Pieter
    Last edited by pietermeulendijk; 12-20-2010 at 12:11 PM. Reason: Question solved

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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