Results 1 to 7 of 7

Thread: step cycle sum

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    may be..

    Code:
    Sub kTest()
        
        Dim r   As Long
        Dim c   As Long
        Dim i   As Long, j As Long
        Dim ka, k(), p
        
        r = Range("e" & Rows.Count).End(3).Row
        c = 12
        
        ka = Range("e3:f" & r)
        
        ReDim k(1 To UBound(ka, 1), 1 To 1)
        
        For i = 1 To UBound(ka, 1) Step c
            j = i
            For r = i To i + c - 1 Step c \ 3
                With Application
                    p = Evaluate("row(" & j & ":" & Application.Min(UBound(ka, 1), j + c - 1) & ")")
                    k(r, 1) = .Sum(.Index(ka, p, 1))
                    k(r + 1, 1) = .Sum(.Index(ka, p, 2)) * -1
                    k(r + 2, 1) = k(r, 1) / k(r + 1, 1)
                End With
                j = j + 1
            Next
        Next
        
        Range("q3").Resize(UBound(k, 1)) = k
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  2. #2
    Senior Member
    Join Date
    Oct 2011
    Posts
    135
    Rep Power
    15
    Hi,

    Thank you so much for the solution.
    Will do the test with real data of the Sheet.

Similar Threads

  1. Click Run cycle
    By PcMax in forum Excel Help
    Replies: 6
    Last Post: 11-01-2011, 04:50 AM
  2. The Sum of A1 + A2 + A3 + A4 = 52
    By stanleydgromjr in forum Excel Help
    Replies: 3
    Last Post: 08-09-2011, 07:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •