+ Reply to Thread
Results 1 to 8 of 8

Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Values

  1. #1
    Registered User
    Join Date
    11-22-2016
    Location
    Dallas, TX
    MS-Off Ver
    2016
    Posts
    3

    Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Values

    I have a workbook that contains monthly sales totals of multiple products for several sales people. Each monthly total is entered as the first day of the month (MM/01/YYYY).

    A B C D E
    1 Date Sales Person Product A Product B Product C
    2 1/1/2015 Bob Jones 411 731 411
    3 2/1/2015 Bob Jones 409 728 413
    4 3/1/2015 Bob Jones 419 938 510
    5 4/1/2015 Bob Jones 408 881 406
    6 5/1/2015 Bob Jones 401 900 411
    7 6/1/2015 Bob Jones 413 694 413
    8 7/1/2015 Bob Jones 404 451 405
    9 8/1/2015 Bob Jones 409 680 465
    10 9/1/2015 Bob Jones 411 752 409
    11 10/1/2015 Bob Jones 411 868 431
    12 11/1/2015 Bob Jones 400 668 409
    13 12/1/2015 Bob Jones 407 836 410
    14 1/1/2011 Ricky Martin 448 639 212
    15 2/1/2011 Ricky Martin 442 838 222
    16 3/1/2011 Ricky Martin 435 959 232
    17 4/1/2011 Ricky Martin 380 504 201
    18 5/1/2011 Ricky Martin 482 895 232
    19 6/1/2011 Ricky Martin 421 787 256
    20 7/1/2011 Ricky Martin 422 800 707
    21 8/1/2011 Ricky Martin 425 694 200
    22 9/1/2011 Ricky Martin 450 717 220
    23 10/1/2011 Ricky Martin 444 841 207
    24 11/1/2011 Ricky Martin 425 646 487
    25 12/1/2011 Ricky Martin 402 614 431

    Excel Help - 1.JPG

    I am attempting to:
    1) Insert a set number of rows based on the number of days in that particular month/year. **(Number of days (-1) due to day one already containing data.**
    2) Auto fill new blank rows with each day of the month in the Date column (MM/DD/YYYY).
    3) Calculate and insert daily average for each product (monthly total / days per month) in the corresponding new row.

    Excel Help - 2.JPG

    Any help or advice will be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    Maybe

    Please Login or Register  to view this content.
    Kind regards
    Leo

  3. #3
    Registered User
    Join Date
    11-22-2016
    Location
    Dallas, TX
    MS-Off Ver
    2016
    Posts
    3

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    Thank you Leo. I am running into a Run time error '1004':

    Error 1004.JPG
    Debug.JPG

    It runs through the last month on the spreadsheet great, but when it gets to the previous month things stop and a negative number is calculated.

    Macro Run.JPG

    Any suggestions?

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    No

    in this file it works



    Kind regards
    Leo
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-22-2016
    Location
    Dallas, TX
    MS-Off Ver
    2016
    Posts
    3

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    I must be doing something wrong or running a different version of excel. I downloaded your spreadsheet and tried to run it with the same results. This is frustrating because I see your results tab, and it is exactly what I am trying to do.

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    and all dates are dates ?
    possible to place the file with the error ?

    Cheers
    Leo

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    excuse the interruption but this may help:

    I downloaded the file and ran the macro and it fails for me too at this line
    Please Login or Register  to view this content.
    Checking at the values of each variable:
    ad= 1 nmdat= 01/01/2012 dat =31/12/2011
    (because: ad = nmdat - dat)

    So code error is due to ad = 1 resulting in vba trying to resize to (0,5)

  8. #8
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: Insert Multiple Rows Based on Days/Month and Fill New Cells with Date and Average Valu

    Maybe with this changes ( marked in red)

    Please Login or Register  to view this content.
    Kind regards
    Leoo

+ 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: 0
    Last Post: 05-26-2016, 05:54 AM
  2. Skip x cells and fill (Fill/create weekly average from 7 days and fill down)
    By tunafishes in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-18-2016, 03:43 AM
  3. Running Average Based on Current number of days in month
    By dw_22801 in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-22-2015, 12:48 PM
  4. Insert rows based on count and fill rows with adjacent values
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-19-2015, 02:57 PM
  5. [SOLVED] Insert Multiple rows based on the values in the cell
    By rlamba in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2014, 09:27 AM
  6. [SOLVED] Auto fill week days based on month chosen
    By mteeters in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-14-2012, 02:45 PM
  7. Pre fill set range off cells with the days of the month
    By Dragonjimbob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-01-2009, 09:03 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