+ Reply to Thread
Results 1 to 13 of 13

Macros with SUMIFS that changes dependent on month

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    Macros with SUMIFS that changes dependent on month

    CAP - Tool for posting.xlsmI need help with both formulas/function AND a macro.
    I have attached a workbook. I am trying to use a macro to fill in the red boxes (I have just made the cells red to make this easier to understand, the macro doesn’t need to do this). The report attached contains several months of data. In this case, the report starts with January. I need formulae that add up the weekday and weekend data. The weekday total –current like (for example, row 146) should add up the figures in the same column that are weekdays (as indicated in column “A”) that are on the current line for the various dates. The next row should add up the “Last Yr,” line and the weekend totals section should do the same for weekends.

    The reason why I think I need a macro to plug in these formulas is the report could change every time it is ran, so I think a macro that searched for the right area of the spreadsheet to add would be brilliant. I’m open to other ideas if there are any. I really appreciate any help you can give.
    Thanks!
    Last edited by WadeLair; 02-12-2013 at 10:53 AM.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    Hi Wadelair,

    Here's a macro for the 24 fields in the red boxes - let me know of any issues:

    Please Login or Register  to view this content.
    Last edited by xladept; 02-14-2013 at 02:36 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macros with SUMIFS that changes dependent on month

    Thank you very much for your help. This works brilliantly, but can you help me understand what is going on a little more?

    Maybe some comments in the block would help me...Thanks again.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    Hi Wadelair - glad you like it - here is a commented version:

    Please Login or Register  to view this content.
    Last edited by xladept; 02-14-2013 at 03:37 PM.

  5. #5
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macros with SUMIFS that changes dependent on month

    CAP - Tool for posting.xlsmSorry to keep picking at this, but I have a few more issues. I think this makes it more complicated. I have uploaded a file again. I want to use the macro to fill in formulas our to column "Y".

    Then, I need some way to stop the process and use formulas to fill in the cells in green. Any ideas?

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    Hi Wadelair,

    I upped all the numbers but had to code a bypass errors - see if it's what you wanted:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macros with SUMIFS that changes dependent on month

    This fills in the cells, but itt does include the ones I colored green.

    Can you think of any way that I could go back and enter formulae in those green cells?

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    Hi Wadelair,

    This will post only in the red cells (They have to be red). What Formulae are you considering?

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macros with SUMIFS that changes dependent on month

    For me, this doesn't populate correctly. This gives a maximum of two rows when the color red is in the cell. Any ideas?

    in column H, the formula is (same row) Column J/F,
    in column I, column K/G.
    In column L, (F/(F+G)).
    In column M, J/HotelSupply
    In column N, (K/(SetCapacity-HotelSupply))
    In column O, M/N



    in column R, the formula is (same row) Column T/P,
    in column S, column U/Q.
    In column V, (P/(P+Q)).
    In column W, T/HotelSupply
    In column X, (U/(SetCapacity-HotelSupply))
    In column Y, W/X

  10. #10
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    The n index wasn't being incremented, for some reason (or no reason at all) the routine was skipping over that code:

    Here's the fix:

    Please Login or Register  to view this content.
    Are SetCapacity-HotelSupply calculated numbers or are they on the sheet under another guise??

  11. #11
    Registered User
    Join Date
    06-19-2012
    Location
    Dallas, Texas
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: Macros with SUMIFS that changes dependent on month

    They are named ranges, their original location is on the "Competitive Set," sheet in the workbook.

  12. #12
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    Please Login or Register  to view this content.
    I get a reference error on Hotel Supply!
    Last edited by xladept; 03-04-2013 at 05:12 PM.

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macros with SUMIFS that changes dependent on month

    You know - since we're overwriting the "green" fields there is no reason to restrict the first writing to only "red" fields:

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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