+ Reply to Thread
Results 1 to 4 of 4

How to AVERAGE using arrays in VBA (No cell references)

  1. #1
    Registered User
    Join Date
    11-02-2018
    Location
    Wolverhampton
    MS-Off Ver
    2015 (Mac) 15.12.3
    Posts
    17

    How to AVERAGE using arrays in VBA (No cell references)

    Hi forum,

    I'd like to calculate an average of the last n values in an array. I plan on creating a loop for n but to keep things simple, let's just say n = 10.

    I would like to calculate an average of the last 10 values in a list. I have written the column to an array and i'd like to use that within VBA, using cell references will take a VERY long time with how many values i'll need to create, especially with a loop for n.

    I can not get my head around how I would achieve this so any help is greatly appreciated.

    I have created and attached a workbook which shows what i'm trying to do.

    Kind regards,
    PercivalP.
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    13,000

    Re: How to AVERAGE using arrays in VBA (No cell references)

    Try:
    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: How to AVERAGE using arrays in VBA (No cell references)

    See if this is how you wanted.
    Please Login or Register  to view this content.
    Last edited by jindon; 08-27-2022 at 11:07 PM.

  4. #4
    Registered User
    Join Date
    11-02-2018
    Location
    Wolverhampton
    MS-Off Ver
    2015 (Mac) 15.12.3
    Posts
    17

    Re: How to AVERAGE using arrays in VBA (No cell references)

    Brilliant! Thank you both. I have taken what you have typed, incorporated it into my main system and it's working. I've not run the whole thing yet but this should be SO much quicker now. Thank you both again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Efficient VBA method for looking up cell values - dynamic sheet references and arrays
    By phor89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2021, 01:04 PM
  2. Replies: 5
    Last Post: 11-12-2018, 10:24 PM
  3. storing multiple value in a single cell (through arrays or without arrays)?
    By mak51061 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-25-2014, 09:27 PM
  4. [SOLVED] Grab 3 cells to left of the cell I need to average without updating references
    By shane01101 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-13-2014, 10:33 AM
  5. VBA store references with arrays
    By fuatt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-25-2013, 07:57 AM
  6. lookup arrays - relative references?
    By jmhultin in forum Excel General
    Replies: 2
    Last Post: 08-09-2009, 07:11 PM
  7. Arrays and range references in VBA
    By Stewart in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-22-2005, 01:05 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