+ Reply to Thread
Results 1 to 5 of 5

average over different cells and not ranges

  1. #1
    Forum Contributor
    Join Date
    12-11-2018
    Location
    Zurich
    MS-Off Ver
    2016
    Posts
    130

    average over different cells and not ranges

    I would like to average over cells in a worksheet over vba userform. I would like to use WorksheetFunction.AverageIf for all values above 0 and also ignore empty cells. The cells are not next to each other, which is why I would not use range. Can someone give me a suggestion?

    Best

  2. #2
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: average over different cells and not ranges

    You could use a "helper range" which points to each of the other ranges, then use the AverageIf on that. i.e., if your ranges are A1:A3 and P43, you could set A10 as =A1, A11 as =A2, A12 as = A3, and A13 as = P43, then use the AverageIf on A10:A13.
    Last edited by gjcase; 01-18-2019 at 03:11 PM.

  3. #3
    Forum Contributor
    Join Date
    12-11-2018
    Location
    Zurich
    MS-Off Ver
    2016
    Posts
    130

    Re: average over different cells and not ranges

    OKey, not sure if I get this right... I defined my values but not sure how to use the AverageIf-Funciton afterwards... Problem is that this is a database, where values are written under each other every time I make a new entry.
    --> My Code looks like that now:

    A1 = CDbl(ActiveSheet.Cells(intErsteLeereZeile, 37).Value)

    A2 = CDbl(ActiveSheet.Cells(intErsteLeereZeile, 41).Value)

    A3 = CDbl(ActiveSheet.Cells(intErsteLeereZeile, 45).Value)


    ActiveSheet.Cells(intErsteLeereZeile, 55).Value = WorksheetFunction.AverageIf(A1,A2,A3,"">0") ->> this is obvioulsy false, but you get the idea what I want...

  4. #4
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: average over different cells and not ranges

    You have an extra double quote in the AverageIf formula, otherwise that should work.

  5. #5
    Forum Contributor
    Join Date
    12-11-2018
    Location
    Zurich
    MS-Off Ver
    2016
    Posts
    130

    Re: average over different cells and not ranges

    tried again, didnt work...

+ 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. Replies: 2
    Last Post: 09-16-2015, 02:17 AM
  2. Get AVERAGE of cells coloured YELLOW in two ranges
    By redspanna in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-13-2015, 04:21 PM
  3. [SOLVED] Getting a weighted average out of ranges
    By Butcher1 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-15-2013, 01:22 PM
  4. Average From Multiple Ranges
    By Caedmonball19 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-24-2013, 05:31 PM
  5. [SOLVED] Take the average of two ranges in VBA
    By niko79542 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-10-2012, 01:33 PM
  6. [SOLVED] Average of last 5 results with two ranges
    By Reanimation in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-09-2012, 07:40 AM
  7. Average Between Date Ranges
    By mycon73 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-11-2009, 03:14 AM

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