Results 1 to 3 of 3

Loop and range problem

Threaded View

  1. #1
    Registered User
    Join Date
    03-20-2012
    Location
    NC
    MS-Off Ver
    Excel 2007
    Posts
    24

    Loop and range problem

    In the code, each of the ranges is of length 8, filled with double values. For this test they are either 0 a 2 digit decimal. The test hangs executing the 1st line in the loop. I tested Max and it equals 8. The 1st debug.print:
    Debug.Print I, O(I, 1), E(I, 1), L(I, 1)
    seems to print out correctly:
    1 0 0.4 0.2
    although I don't fully understand what's happening in the print out [why does it repeat 3 times?]:
    1 0 0.4 0.2
    1
    1 0 0.4 0.2
    1
    1 0 0.4 0.2
    1
    Function sniff(core As Double, lim As Double, Baser As Range, Extra As Range, Opn As Range, _
            Clse As Range, Last As Range, Preset As Range, ndx As Integer) As Double
        
        Dim MAX As Integer, sum As Double, num As Integer, I As Integer, scal As Double
    
        Dim doit(8)
        Dim B()
        Dim E()
        Dim O()
        Dim C()
        Dim L()
        Dim P()
    
        
        MAX = Baser.Rows.Count
        B = Baser
        E = Extra
        O = Opn
        C = Clse
        L = Last
        P = Preset
    
    
            sum = core
            num = 0
            For I = 1 To MAX
                num = num + 1
                Debug.Print I, O(I, 1), E(I, 1), L(I, 1)
                If O(I, 1) = 1 Then doit(I) = E(I, 1) Else doit(I) = L(I, 1)
                
             '   If C(I, 1) = 1 Then
             '       If P(I, 1) > 0 Then doit(I) = minf(doit(I), P(I, 1)) Else doit(I) = 0
             '   End If
                Debug.Print num
    
                sum = sum + doit(I)
            Next I
                Debug.Print sum
    Last edited by jalea148; 06-29-2012 at 03:22 PM.

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