Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Microsoft Office и VBA программирование > Microsoft Office Excel
Регистрация

Восстановить пароль

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 23.08.2009, 03:02   #1
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию Combining Coinciding Results.

Hello!
I wonder if it is possible to do the following with the help of the formulas alone. I have a list of events which START and END at different times. Some of them start when the other events are still in progress (their end date has not been reached yet). I need a way to combine the results of the events whose times overlap. The results of the overlapping events should be multiplied and stored as a single event. Any help will be hugely appreciated!
Thanks a lot!)
Вложения
Тип файла: zip events.zip (30.8 Кб, 12 просмотров)
london735 вне форума Ответить с цитированием
Старый 23.08.2009, 03:28   #2
EducatedFool
Программист VBA
СуперМодератор
 
Аватар для EducatedFool
 
Регистрация: 13.07.2008
Сообщений: 6,858
По умолчанию

You can use the formulas like the following:
Код:
    Cell: H9      Formula  (style A1):   =DATE(A9,B9,C9)-DATE(D8,E8,F8)
                  Formula  (style R1C1): =DATE(RC[-7],RC[-6],RC[-5])-DATE(R[-1]C[-4],R[-1]C[-3],R[-1]C[-2])

    Cell: H10     Formula  (style A1):   =DATE(A10,B10,C10)-DATE(D9,E9,F9)
                  Formula  (style R1C1): =DATE(RC[-7],RC[-6],RC[-5])-DATE(R[-1]C[-4],R[-1]C[-3],R[-1]C[-2])
For multiplying results of the overlapping events use
Код:
    Cell: J8      Formula  (style A1):   =PRODUCT(I8:I1901)
                  Formula  (style R1C1): =PRODUCT(RC[-1]:R[1893]C[-1])
EducatedFool вне форума Ответить с цитированием
Старый 23.08.2009, 14:44   #3
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию

Hello! Thanks for your help - I guess the formula should subtract the dates in the reverse order. Also as you see there can be MORE THAN ONE event which overlap - do you think that formula that you provided can account for this - or it is better done with the array formulas?

Последний раз редактировалось london735; 24.08.2009 в 03:35.
london735 вне форума Ответить с цитированием
Старый 24.08.2009, 06:52   #4
SAS888
Старожил
 
Аватар для SAS888
 
Регистрация: 05.12.2007
Сообщений: 4,180
По умолчанию

I can offer other example with user's function.
See attachment. Pay attention to formula in cell "J7".
Вложения
Тип файла: rar EVENTS_2.rar (32.0 Кб, 10 просмотров)
Чем шире угол зрения, тем он тупее.
SAS888 вне форума Ответить с цитированием
Старый 24.08.2009, 14:12   #5
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию

thank you for your help) can you please explain this formula? do you think it is possible to do it in such a way so that the individual combination results are visible? Many thanks as usual)
london735 вне форума Ответить с цитированием
Старый 25.08.2009, 05:26   #6
SAS888
Старожил
 
Аватар для SAS888
 
Регистрация: 05.12.2007
Сообщений: 4,180
По умолчанию

This is user function, as I spoke already. Here is code to this function, which is found in software module:
Код:
Function Prod(rng As Range) As Double
    Dim i As Long, a()
    a = rng.Value: On Error Resume Next: Prod = a(1, 7)
    For i = 2 To UBound(a, 1)
        If CDate(a(i, 1) & " " & a(i, 2) & " " & a(i, 3)) >= _
        CDate(a(i - 1, 4) & " " & a(i - 1, 5) & " " & a(i - 1, 6)) Then Prod = Prod * a(i, 7)
    Next
End Function
That You not understandable here? The Function Prod(range) must have 7 columns without fall. The first 3 columns - there is begin each period (year, month and day accordingly). The following 3 columns - there is end of each period (in same desksides). The seventh column - there is result. The function places whole specified range in array. Then, is organized cycle, in which we search for the overlapping a periods, and if we find not overlaying periods, that multiplies the accumulating result (Prod).
Чем шире угол зрения, тем он тупее.
SAS888 вне форума Ответить с цитированием
Старый 25.08.2009, 16:29   #7
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию

Dear Sas,
thank you for your kind explanation. I have to tell you that I need the individual results of the overlapping events recorded in a separate column so that I can review them when I need this....Can you please help me to do this?)
Thanks!)
london735 вне форума Ответить с цитированием
Старый 26.08.2009, 04:59   #8
SAS888
Старожил
 
Аватар для SAS888
 
Регистрация: 05.12.2007
Сообщений: 4,180
По умолчанию

The user formula, which I offer, solves your problem without additional columns and cells. EducatedFool gave the decision by means of formulas for the individual results already. Is it made wrong something?
Чем шире угол зрения, тем он тупее.
SAS888 вне форума Ответить с цитированием
Старый 30.08.2009, 22:27   #9
london735
Пользователь
 
Регистрация: 20.06.2008
Сообщений: 45
По умолчанию

Hello! Many thanks for your help! Can you please help me to calculate the number of CONCURRENT events which correspond to each of the events which happens (I mean the number of events which occur AT THE SAME TIME). I need this number next to each of the events...Do you think it can be done by formulas alone?
Thank you again very much for your help!)
london735 вне форума Ответить с цитированием
Старый 30.08.2009, 23:05   #10
motorway
Участник клуба
 
Регистрация: 28.06.2009
Сообщений: 1,950
По умолчанию

What events do you mean?
motorway вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц



Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Combining Two Tables london735 Microsoft Office Excel 4 10.07.2009 13:58