+ Reply to Thread
Results 1 to 7 of 7

Averaging data in one column based on an interval in another

  1. #1
    Registered User
    Join Date
    07-27-2021
    Location
    Hamilton
    MS-Off Ver
    Microsoft Office Professional Plus 2019
    Posts
    4

    Averaging data in one column based on an interval in another

    Hi,

    I would appreciate a VBA code (or excel functions if they are easy) that will average the data in columns B-H based on the interval of 0.00-0.50m in column A.

    An example of how the processed data should appear has been done in Columns J-Q.

    I am looking to process over 100 spreadsheets in a similar manner, so creating a pivot table for each individual spreadsheet is not ideal.

    Cheers
    Attached Files Attached Files
    Last edited by jack.elvy; 09-21-2021 at 12:36 AM.

  2. #2
    Forum Contributor
    Join Date
    06-20-2021
    Location
    UK
    MS-Off Ver
    2016
    Posts
    126

    Re: Averaging data in one column based on an interval in another

    This can be done with Pivot Table. Use col A as rows, and divide that into intervals, and set Value to average.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,792

    Re: Averaging data in one column based on an interval in another

    Your ranges cover:

    B2:B52
    B53:B102
    B103:B152

    For consistency, shouldn't the first range be:

    B3:B52

    Also, in cell O2 you have this:

    =MEDIAN(F2:F50)

    which is inconsistent with the other ranges.

    Pete

  4. #4
    Registered User
    Join Date
    07-27-2021
    Location
    Hamilton
    MS-Off Ver
    Microsoft Office Professional Plus 2019
    Posts
    4

    Re: Averaging data in one column based on an interval in another

    Thanks for the replies.

    I could do it with a pivot table however I am looking to apply a code or simply copy paste formulas over to apply this to voer 100 spreadsheets to process them in a similar manner.

    I should have mentioned this previously!

    As for the inconsistency, it is because I am counting the 0.00m as being part of the first 0.5m interval, it does not have a significant impact on the rest of the data.

  5. #5
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,792

    Re: Averaging data in one column based on an interval in another

    You can use this formula in J2:

    =INDEX(A:A,ROWS($1:1)*50+2)

    and this one in K2:

    =MEDIAN(INDEX(B:B,(ROWS($1:1)-1)*50+3):INDEX(B:B,ROWS($1:1)*50+2))

    Copy K2 across to Q2, then you can copy the block of formulae in J2:Q2 down as far as you need to.

    Note that these use consistent ranges, i.e. rows 3 to 52, rows 53 to 102, rows 103 to 152 and so on, so the results on the first row are slightly different than yours. If you want then to be exactly the same, you can use this in K2:

    =MEDIAN(INDEX(B:B,(ROWS($1:1)-1)*50+IF(ROWS($1:1)=1,2,3)):INDEX(B:B,ROWS($1:1)*50+2))

    with the changes shown in red. Copy across and down as before.

    Hope this helps.

    Pete

  6. #6
    Registered User
    Join Date
    07-27-2021
    Location
    Hamilton
    MS-Off Ver
    Microsoft Office Professional Plus 2019
    Posts
    4

    Re: Averaging data in one column based on an interval in another

    Thanks for that Pete, however I am getting 'there is a problem with this formula' for both J2 and K2.

  7. #7
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,792

    Re: Averaging data in one column based on an interval in another

    You must have typed them in incorrectly. I've attached the file that I worked on this morning. I put the formulae further to the right starting in column S, so that you can compare the results directly with your own values.

    Hope this helps.

    Pete
    Attached Files Attached Files

+ 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] Averaging cells in one column, based on another
    By alarai in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-21-2021, 04:20 PM
  2. Replies: 5
    Last Post: 03-31-2015, 03:24 PM
  3. Replies: 1
    Last Post: 04-29-2014, 04:42 AM
  4. Help With Conditional Averaging Based On Column Header...
    By jeffgreg in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-15-2014, 08:56 PM
  5. [SOLVED] Averaging a column based on boundaries set at a different column
    By Kybynn in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 01-11-2013, 10:39 AM
  6. Averaging based on different Column
    By corky1111 in forum Excel General
    Replies: 5
    Last Post: 08-12-2011, 02:12 PM
  7. Macro -Equal Interval Averaging
    By Mortonium in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-03-2007, 05:38 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