Results 1 to 4 of 4

Calculate average of variable number of cells variable number of times

Threaded View

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    Netherlands-Venlo
    MS-Off Ver
    Excel 2010
    Posts
    9

    Calculate average of variable number of cells variable number of times

    See attached file. Current logic:
    For every iteration a random value is selected with formula in cell E3 and copied to next free cell in Column G.

    What I want to add is the following:
    User selects number of iterative steps in cell E1 and number of forecast periods in cell E2, e.g. 6. In this case for every iteration 6 random values will be selected by formula in cell C3 and from that 6 the average must be calculated. This average value will be copied into the next free cell of column G. The step from selecting number of random values, calculating average of that and placing into the next free cell of column G will be iterative to value of cell E1.

    Problem is that I am not able to get the correct vba code.......

    Sub Randomnumber()
    Application.ScreenUpdating = False
    Range("E3").Name = "Source"
    Columns("G").Clear
    Range("G1").Value = "Values"
    Iteraties = Range("E1").Value
    teller = 1
    Do While teller <= Iteraties
            Range("Source").Copy
            Range("Destination").Offset(teller - 1, 0).PasteSpecial (xlValues)
            teller = teller + 1
    Loop
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    ActiveSheet.PivotTables("PivotTable1").PivotCache.Refresh
    MsgBox ("Calculation is ready and pivottable is updated")
    End Sub
    Attached Files Attached Files
    Last edited by WeirnetherlandsBart; 11-06-2014 at 04:34 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 9
    Last Post: 06-24-2014, 02:56 PM
  2. Perform an operation a variable number of times
    By mutantpanda in forum Excel General
    Replies: 2
    Last Post: 01-29-2014, 04:10 AM
  3. Replies: 6
    Last Post: 04-14-2012, 04:07 AM
  4. [SOLVED] Average variable number of cells
    By kayard in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-29-2008, 04:22 AM
  5. Counting the number of times more than 1 variable occurs
    By chrisdedobb in forum Excel General
    Replies: 5
    Last Post: 01-03-2006, 02:20 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