+ Reply to Thread
Results 1 to 17 of 17

Calculate events during a certain period

  1. #1
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Question Calculate events during a certain period

    Hi experts,

    Need some help...
    Iīm trying to make a calculation based on static events during a certain period (weeks), but when you move forward to the following week I want to keep the same information on that cell, to have something like a time evolution.

    Maybe an example will more clear,

    Events type nš events date week Event A Event B
    A 5 1 5 10
    B 10 2

    So if in week 2, event A = 10 and event B = 8, I would like to maintain the previous values in the week 1,
    and so on, ...

    does this makes any sense?
    Thank you for your support
    Last edited by vsousa; 06-05-2014 at 10:50 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Calculate events during a certain period

    Is week number in the data?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    No, the Data doesn't have Week information.
    The relation with time will be made through the formula today()

  4. #4
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    My idea was that the column date week has the seven days of week, letīs say this week 2-6-2014 to 8-6-2014,
    next week 9-6-2014 to 15-6-2014.
    Using the formula TODAY() I can define which is the specific week, and insert the information from the table below,
    Like copy paste information according the data on the present week,

    (this table is constantly changing)
    Events type Number of events
    A 5
    B 10

    On the following week I need to hold those values in week 1 (2-6-2014 to 8-6-2014), and insert the new ones to other row (9-6-2014 to 15-6-2014)
    Events type Number of events
    A 10
    B 8

    The objective is that the end result is like this:
    date week Event A Event B
    2-8-2014 / 8-6-2014 5 10
    9-6-2014 / 15-6-2014 10 8

    Is it possible?
    Last edited by vsousa; 06-05-2014 at 10:03 AM.

  5. #5
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    ..............
    Last edited by vsousa; 06-06-2014 at 03:39 AM.

  6. #6
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Added a file, maybe I'm not explaining well

    Item A changes each week, and when we go to week 24, I would like to keep the information from previous week,

    is it possible?

    Thank you
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Up, canīt solve this in automatically way, I could use like a paste special every week to hold those values, but the intention was having a mechanism for doing this,

  8. #8
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Calculate events during a certain period

    with an pivot table.

    I added some new data (marked blue).

    See the attached file.
    Attached Files Attached Files
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Calculate events during a certain period

    Please find the attachment to see if this is something you can work with.
    Attached Files Attached Files
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  10. #10
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Oeldere, thanks for your effort,

    But when you update the pivot table it will have the same effect, updating the information to the following week and deleting the information from the previous one, or I didnīt understand the logic?
    Last edited by vsousa; 06-06-2014 at 05:34 AM.

  11. #11
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Quote Originally Posted by sktneer View Post
    Please find the attachment to see if this is something you can work with.
    Iīve added some comments in the file, and the formulas in column E
    Attached Files Attached Files

  12. #12
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Calculate events during a certain period

    See the attached sheet.
    Attached Files Attached Files
    Last edited by sktneer; 06-06-2014 at 06:34 AM.

  13. #13
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Thanks sktneer your macro does solve the raised problem,
    is there any way I can reproduce what you did by a macro but through a formula? (I'm not a great vba programmer)

    If not what should I copy from your macro to add extra columns where it gets information from a specified cell?

    -----------------------------------------------------------------------------------------------------------------
    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng, cell As Range
    Dim lr, n As Long
    lr = Cells(Rows.Count, 1).End(xlUp).Row
    Set rng = Range("A3:A" & lr)
    Application.EnableEvents = False
    If Not Intersect(Target, Range("H25")) Is Nothing Then
    For Each cell In rng
    If WorksheetFunction.WeekNum(cell, 2) = WorksheetFunction.WeekNum(Date, 2) Then
    n = cell.Row
    Exit For
    End If
    Next cell
    Cells(n, "E") = Cells(25, "H")
    End If
    Application.EnableEvents = True
    End Sub

    -------------------------------------------------------------------------------------------------------------------------------

  14. #14
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Calculate events during a certain period

    reply to your question in #10

    If you add new data in your table and refresh the pivot table you have the total of the item during the year (and the total per week).

  15. #15
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Quote Originally Posted by oeldere View Post
    reply to your question in #10

    If you add new data in your table and refresh the pivot table you have the total of the item during the year (and the total per week).
    Hi Oeldere,

    When you update the pivot table you will have the same problem, because you use a column to define which is the present week,
    the ones that are not return 0 " =IF(D27=1;$H$25;0) "
    the pivot table will not hold the values for the past weeks, or are you suggesting a different approach?

  16. #16
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Calculate events during a certain period

    I suggest you not select only the last week, but select all weeks.

    It will give you much more information.

    New added data will automatic be in the pivot table if you refresh the pivot table.

  17. #17
    Registered User
    Join Date
    05-06-2013
    Location
    AO
    MS-Off Ver
    office 365
    Posts
    14

    Re: Calculate events during a certain period

    Hi,

    Some time I didnīt look at this again, but today founded a solution through a formula instead of using a Macro (that would solve this, but I'm not a "pro" in vba),using a circular reference I was able to hold the value of past week, you will get an alarm about his, then is a matter of going to Excel option > Formulas, and Enable iterative calculation check box, better explained here http://office.microsoft.com/en-us/ex...010066243.aspx

+ 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: 1
    Last Post: 04-24-2013, 11:38 PM
  2. Replies: 12
    Last Post: 12-12-2012, 01:55 AM
  3. [SOLVED] Complicated:Calculate time period based on no. of units sold + fluctuations within period
    By omaha.crab in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2012, 03:04 AM
  4. Calculate period in day
    By rich3101 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-12-2007, 11:21 AM
  5. How to calculate period
    By manan in forum Excel General
    Replies: 3
    Last Post: 05-12-2006, 10:10 AM

Tags for this Thread

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