+ Reply to Thread
Results 1 to 6 of 6

Grouping Range of Weeks to Specific Month and find the average of the values

Hybrid View

Vinod Krishna.C Grouping Range of Weeks to... 05-17-2018, 03:23 PM
David A Coop Re: Grouping Range of Weeks... 05-17-2018, 10:45 PM
Vinod Krishna.C Re: Grouping Range of Weeks... 05-18-2018, 02:11 AM
David A Coop Re: Grouping Range of Weeks... 05-19-2018, 04:30 AM
David A Coop Re: Grouping Range of Weeks... 05-21-2018, 02:39 AM
Vinod Krishna.C Re: Grouping Range of Weeks... 05-22-2018, 12:52 AM
  1. #1
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2016
    Posts
    110

    Grouping Range of Weeks to Specific Month and find the average of the values

    Dear all,

    My Goal is to find the average of allocation of resources for specific weeks and group them into specific month for dynamic range using formula.

    Ex:

    A B C D E
    Emp No 05/19/2018 05/26/2018 06/02/2018 06/09/2018 06/16/2018
    1 25 75 0 0 100
    2 0 0 25 25 25

    In the end, i.e. after the last columns, output against 1 should be:

    May-18 =AVERAGE(A2:B2)
    Jun-18 =AVERAGE(C2:E2)

    In the end, i.e. after the last columns, output against 2 should be:

    May-18 =AVERAGE(A3:B3)[/
    Jun-18 =AVERAGE(C3:E3)[/

    But, it should be based on formula using range of column. Please see columns AL through AT.

    PFA for the sheet with error.

    Request your help in fixing this code and improvising the same.

    Thanks,
    Vinod Krishna
    Attached Files Attached Files
    Last edited by Vinod Krishna.C; 05-18-2018 at 02:09 AM.

  2. #2
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Grouping Range of Weeks to Specific Month and find the average of the values

    Try this formula - I think it was introduced in 2007.

    =IFERROR(AVERAGEIFS($B2:$AK2,$B$1:$AK$1,">="&AL$1,$B$1:$AK$1,"<="&EOMONTH(AL$1,0)),0)

    You will need to change the headings in AL1:AT1 to dates. They are entered as text in your version.

    I hope this helps, please let me know!

    Regards,

    David

    If this has been helpful
    - Please click on the *Add Reputation button at the bottom left.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".


  3. #3
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2016
    Posts
    110

    Re: Grouping Range of Weeks to Specific Month and find the average of the values

    Thanks for the formula David. It works.

    However, I want to achieve this using VBA.

    Perhaps, my requirement was confusing. I had updated my original post.

    Could you please help me correct the VBA logic.

    Thanks,
    Vinod Krishna

  4. #4
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Grouping Range of Weeks to Specific Month and find the average of the values

    Hi Vinod,

    Before I discuss the VBA, I should state that I usually prefer a formula solution - especially where you are using VBA to enter a formula.

    That said, I have written a new macro for you. (It is below your old one).

    It is considerably shorter than yours - I hope it is doing what you want it to.

    I suggest you work your way through it, and see if you can follow what I have done.

    Basically, I work my way across the dates in row 1, and every time the month changes, I place the month heading on row 1, and a formula on row two.
    When this is finished, the macro then copies the formula down.

    This is a lot quicker than your approach, which was slow.

    Have a look at the formula! Your method was incorrect - you have to use the R1C1 formula structure.

    I hope this helps, please let me know!

    Regards,

    David

    If this has been helpful
    - Please click on the *Add Reputation button at the bottom left.

    Please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".

    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    11-26-2013
    Location
    Colac, Victoria, Australia
    MS-Off Ver
    Excel 2016
    Posts
    1,309

    Re: Grouping Range of Weeks to Specific Month and find the average of the values

    Hi Vinod,

    Thanks for letting me know that the code I provided worked (and for the rep).

    Please mark the thread as SOLVED so that other members of the forum don't spend time looking into your query.

    David

  6. #6
    Forum Contributor
    Join Date
    06-05-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2016
    Posts
    110

    Re: Grouping Range of Weeks to Specific Month and find the average of the values

    Sure David. It is marked as Solved.

    Regards,
    Vinod Krishna

+ 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. Formula to sum data by month from range with weeks
    By MetteGaga in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-10-2016, 05:42 AM
  2. Using =SUMIF,=COUNTIF, and =AVERAGE to find specific values in columns
    By ExcelNub83 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-07-2015, 07:53 PM
  3. [SOLVED] Need to find average of an array if corresponding values are within a set range
    By Pallav001 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-21-2013, 03:06 AM
  4. Replies: 2
    Last Post: 11-21-2012, 05:59 AM
  5. Grouping Weeks to Month in Pivot Table
    By himanshututeja in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-18-2012, 01:59 PM
  6. How to find if new month started between weeks?
    By nmlnml in forum Excel General
    Replies: 1
    Last Post: 11-04-2009, 06:10 AM
  7. Find average of the specific month
    By Salomey in forum Excel General
    Replies: 3
    Last Post: 10-16-2009, 06:54 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