+ Reply to Thread
Results 1 to 11 of 11

Problem with a variable on a Sum formula using Offset to count days of the month every Thu

  1. #1
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Question Problem with a variable on a Sum formula using Offset to count days of the month every Thu

    Hello!

    I have a worksheet where every tab needs to be a month of the year, and every Thursday I have to report certain sums of the columns from the tabs. After some trial and errors I managed to get a formula to do that, but it had a minor setback: the weeks between months donīt count the previous tabs.

    So here I am trying to fix that issue, I have considered using SUM and OFFSET, COUNTA and even INDEX to get it right; but I am not being able to have it done what I need.

    The attachment contains a small draft of the worksheets and its tabs and here is briefing on the columns formulas and what was supposed to do:
    Columns N, P and E will calculate the last 7 days of operations, if it is a Wednesday. The formula is:

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




    I used the months of July, August and September as example, on the Sep2019 tab the value on cell N8 should return the 4 days prior September 5th and should also calculate the 3 days from the Aug2019 tab. Here is the point I canīt seem to build the formula correctly, since I have to deal with months that ends on 28, 29 (Leap Years), 30 or 31.

    Hope someone can help me with this conundrum!

    Cheers,
    Diogo Cuba
    Attached Files Attached Files

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    Try these formulas in N5:S5

    Please Login or Register  to view this content.
    Then copy the formula down from N5:S5 to N6:S35. That should help retrieve data from the previous sheets.

    See attached.

    WBD
    Attached Files Attached Files
    Office 365 on Windows 11, looking for rep!

  3. #3
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    Thanks for the input, WideBoyDixon.

    I have downloaded the file and did some tests, unfortunately they are not counting the dates from 29-31AUG on the previous tab and is summing only the columns from the tab of September.

  4. #4
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    The sheet I uploaded has 84 in N8 on the September tab; achieved by summing up the 1-4 September + 29-31 August.

    WBD
    Attached Images Attached Images
    Last edited by WideBoyDixon; 07-11-2019 at 04:27 AM.

  5. #5
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    The file I have downloaded shows 48 on N8, on the tab Sep2019.

    This is the formula on it:

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


    Any chance you can upload it again?

  6. #6
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    I suspect that your regional settings mean that the months don't come out as English. If you hit Alt+F11 to go into the editor, click Ctrl+G to open the immediate window and type the following:

    Please Login or Register  to view this content.
    Then hit return, I'm guessing it doesn't say "Aug2019" as the answer.

    WBD

  7. #7
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    So I wrote a function instead:

    Please Login or Register  to view this content.
    Which I then used in, say, N5:

    Please Login or Register  to view this content.
    This hard-codes the month names and makes the formula a bit simpler. Take a look.

    WBD
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    Indeed it returns "ago2019"...

  9. #9
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    Quote Originally Posted by WideBoyDixon View Post
    So I wrote a function instead:

    Please Login or Register  to view this content.
    Which I then used in, say, N5:

    Please Login or Register  to view this content.
    This hard-codes the month names and makes the formula a bit simpler. Take a look.

    WBD
    Thatīs an amazing solution, man. I have just added a piece of code to the function to make it volatile: "Application.RefreshAll" since at first it seemed not to be working...


  10. #10
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    Actually I used:

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-10-2019
    Location
    Rio de Janeiro, Brazil
    MS-Off Ver
    2016;2019; Office 365
    Posts
    19

    Re: Problem with a variable on a Sum formula using Offset to count days of the month every

    Quote Originally Posted by WideBoyDixon View Post
    So I wrote a function instead:
    ...
    WBD
    I appreciate a lot of your time and effort, man!

    Can I bother you a little bit more to help undertand this piece of code?

+ 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. Calc days in month when full and variable month for a budget report
    By JOHNAK27 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-10-2018, 03:29 PM
  2. Replies: 16
    Last Post: 08-22-2017, 11:20 AM
  3. Replies: 3
    Last Post: 03-21-2016, 02:01 PM
  4. Replies: 8
    Last Post: 12-04-2013, 04:14 AM
  5. How to calculate days of supply given variable demand per month
    By hkaushal in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-14-2013, 10:31 AM
  6. Problem with Offset / Count Formula
    By blackbadger in forum Excel General
    Replies: 1
    Last Post: 08-19-2010, 05:14 AM
  7. How to count # of days in a month from a list of days
    By vinnygamz in forum Excel General
    Replies: 3
    Last Post: 07-20-2009, 05:02 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