Results 1 to 10 of 10

Thread: Evaluate("SUM

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Member
    Join Date
    Oct 2011
    Posts
    135
    Rep Power
    15
    Hi,

    Did you mean like this:

    Code:
    Sub snb()
      Sn = Sheets(1).Columns(3).SpecialCells(2)
      Sn1 = Sn
      For j = 11 To UBound(Sn)
        Sn1(j, 1) = (Sn(j, 1) + Sn(j - 1, 1) + Sn(j - 2, 1) + Sn(j - 3, 1) + Sn(j - 4, 1) + Sn(j - 5, 1) + Sn(j - 6, 1) + Sn(j - 7, 1) + Sn(j - 8, 1) + Sn(j - 9, 1)) / 10
      Next
      Cells(1, 15).Resize(UBound(Sn)) = Sn1
      Cells(2, 15).Resize(9).ClearContents
    End Sub
    Keep in mind that the value 10 in range L2 I can edit ( 1, 2,,,10, 11, 12,,, ecc)

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    This code seems to produce the same answer as the code you posted...

    Code:
    Sub Test_B()
      Dim LastRow As Long
      LastRow = Range("C" & Rows.Count).End(xlUp).Row
      With Range("O" & Range("L2").Value + 1 & ":O" & LastRow)
        .Formula = "=SUM(OFFSET(C$1:C$" & Range("L2").Value & ",ROW(A1),0))/L$2"
        .Value = .Value
      End With
    End Sub

Similar Threads

  1. VBA Versions of my "Get Field" and "Get Reverse Field" formulas
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 4
    Last Post: 06-02-2017, 06:15 PM
  2. Reversing a "First Middle Last" Name to "Last, First Middle" Name Format
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 5
    Last Post: 01-06-2014, 10:04 PM
  3. Replies: 5
    Last Post: 04-18-2013, 02:30 AM
  4. Follow-up to "Excel Number Format: Indian Style Comma Separation"
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 2
    Last Post: 04-14-2012, 10:46 PM
  5. Ordinal Suffix (i.e., "st", "nd", "rd" and "th")
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 0
    Last Post: 03-20-2012, 03:46 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
  •