+ Reply to Thread
Results 1 to 6 of 6

Macro to auto-populate cells based on content of other cells

  1. #1
    Registered User
    Join Date
    06-06-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    48

    Macro to auto-populate cells based on content of other cells

    I think what I want to do here is easiest illustrated by a 'Before' and 'After' spreadsheet - see attached.

    You'll see in the 'Before' spreadsheet at B13-16 there are a range of '1s' and in the column immediately to the right, various different numbers.

    I would like a macro to identify all the '1s' in this column and then insert a cell in C13 averaging all the numbers immediately to the right of a '1' in column B. The average should go in C3. Then do the same thing for all the '2s' with the average going in C4, and the same thing for the 3s in C5.

    See the 'After' spreadsheet for what I mean.

    I know it's possible to design macros where the actions are based on cell contents. Can this be done here?

    Thanks in advance!
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Macro to auto-populate cells based on content of other cells

    Try this.
    PHP Code: 
    =AVERAGEIF($B$12:$B$33,B3,$C$12:$C$33

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to auto-populate cells based on content of other cells

    Hi,

    It doesn't need a macro.

    The simple function

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    in B3 copied down will do.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    06-06-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    48

    Re: Macro to auto-populate cells based on content of other cells

    Thanks, this is very helpful and deals with the question as expressed.

    Unfortunately I didn't give the full question (to keep things simple). The actual spreadsheets I'm looking at are a bit more complex. They aren't just using the 'average' function but, in some cases, are producing a weighted geometric mean. This involves an addition column setting out the weights.

    I've attached a different 'Before' and 'After' spreadsheet. It would be lovely if this could be done with something like AVERAGEIF but maybe this one does need a macro?

    Thanks for the help/ quick responses.
    Attached Files Attached Files
    Last edited by BristolJGM; 07-05-2015 at 01:39 PM.

  5. #5
    Registered User
    Join Date
    06-06-2015
    Location
    London, England
    MS-Off Ver
    365
    Posts
    48

    Re: Macro to auto-populate cells based on content of other cells

    Bump - did anyone have any thoughts on this?

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Macro to auto-populate cells based on content of other cells

    Hi,

    It's important when you put your question that your example data represents your real life data otherwise we all waste a lot of time.
    In this case I have no idea how you've calculated your results. They don't appear to accord with any weighted geometrically or even arithmetic mean that I can see.

    Explain your workings.

+ 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. Auto-Populate Cells based on a dropwn
    By danallamas in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-27-2014, 12:57 AM
  2. [SOLVED] Can I Auto populate cells based on value in another cell
    By Rednecknerd in forum Excel General
    Replies: 2
    Last Post: 12-11-2013, 10:58 AM
  3. [SOLVED] Help with auto-population based the content of other 2 cells
    By denisirio in forum Excel General
    Replies: 3
    Last Post: 10-08-2013, 03:33 PM
  4. [SOLVED] Macro to Auto-populate cells and columns based off of a Number
    By Cansa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-06-2013, 05:59 PM
  5. Auto populate cells based on 2 cells division.
    By Chance224 in forum Excel General
    Replies: 0
    Last Post: 04-04-2005, 05:06 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