Workplan - Sumproduct formula - Heavy calculation issue.

Godeled

New Member
Joined
Dec 8, 2019
Messages
1
Office Version
  1. 2019
Platform
  1. Windows
Hi everybody,

I tried to make a workplan file that can automatically fill two sheets: weekly (cf weekly consolidation screenshot) and monthly (cf monthly consolidated screenshot) plan based on the daily data input in a third sheet (daily, cf daily data inputs) to ease the reporting tasks at work, and facilitate visualisation + extraction of data. (My workfield, humanitarian aid, is particularly reporting heavy)

At first, I used the following formula : SOMMEPROD((Daily!$C$8:$C$250=$D10)*(Daily!$L$4:$SE$4=L$8)*(Daily!$L$1:$SE$1=L$7)*(Daily!$L$8:$SE$250)) applied to all the different week and activities (cf formula screenshot).
But since we have very old and inefficient computers in the context I am working, it took forever to calculate and display the data in the two linked sheets (monthly and weekly)

Hence, to mitigate this I tried to work on a small VBA code that would calculate the result of the sumproduct formula directly when you hit a button, but the following code took a whooping 27 min to complete its calculation on the working computers of the office. (cf the following code)

VBA Code:
Sub Macroplan()

    Dim rngAct As Range, rngMon As Range, rngYea As Range, rngVal As Range
    Dim Month As String, Year As String, Activity As Variant
    Dim i As Integer, j As Integer
    Dim myFormula As Variant
   
    myFormula = "SUMPRODUCT((<plageYear>=<Y>)*(<plageMonth>=<M>)*(<plageACT>=<A>)*(<plageValue>))"
   
    With ThisWorkbook.Sheets("Daily")
        Set rngAct = .Range("$C$8:$C$250")
        Set rngYea = .Range("$L$1:$SE$1")
        Set rngMon = .Range("$L$4:$SE$4")
        Set rngVal = .Range("$L$8:$SE$250")
    End With
     
    For i = 1 To 70 '70
        For j = 1 To 243 '243
            With ThisWorkbook.Worksheets("Weekly")
                Year = .Cells(7, 11 + i)
                Month = .Cells(8, 11 + i)
                Activity = Chr(34) & .Cells(9 + j, 4) & Chr(34)
            End With
   
            If Cells(9 + j, 4).Value <> 0 Then
                myFormula = Replace(myFormula, "<Y>", Year)
                myFormula = Replace(myFormula, "<M>", Month)
                myFormula = Replace(myFormula, "<A>", Activity)
                myFormula = Replace(myFormula, "<plageYear>", rngYea.Address(external:=True))
                myFormula = Replace(myFormula, "<plageMonth>", rngMon.Address(external:=True))
                myFormula = Replace(myFormula, "<plageACT>", rngAct.Address(external:=True))
                myFormula = Replace(myFormula, "<plageValue>", rngVal.Address(external:=True))
                Debug.Print myFormula
                Cells(9 + j, 11 + i).Value = Application.Evaluate(myFormula)
                myFormula = "SUMPRODUCT((<plageYear>=<Y>)*(<plageMonth>=<M>)*(<plageACT>=<A>)*(<plageValue>))"
                Debug.Print myFormula
            End If
                           
        Next
    Next

End Sub

As I am a bit out of ideas and that fresh eyes would help (because I might be overcomplicating things) any help would be much appreciated in lightening the file., or using a better approach/methodology :) .

I apologize in advance if the subject was already treated (i didn't find a directly related topic with a quick search)

Many thanks,
 

Attachments

  • Daily data inputs.jpg
    Daily data inputs.jpg
    53.6 KB · Views: 6
  • Formula.jpg
    Formula.jpg
    48.3 KB · Views: 4
  • Monthly consolidation.jpg
    Monthly consolidation.jpg
    47.9 KB · Views: 4
  • Weekly consolidation.jpg
    Weekly consolidation.jpg
    51 KB · Views: 5
Last edited by a moderator:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
I always enclose my code with the following code, whether it is needed.

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
................
................

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
 
Upvote 0
Hi, I could help you, but I think, that we would need check your data structure
If you can, give another example, explaining what data you have, what conditions they meet, what they should add and what result you expect.

Please, try prepare a data example using add-in specifically for this and it can be found here XL2BB
Pay attention to this post XL2BB 2 Squares
 
Upvote 0

Forum statistics

Threads
1,215,643
Messages
6,125,990
Members
449,277
Latest member
Fanamos298

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top