-
Notifications
You must be signed in to change notification settings - Fork 1
/
SummaryUpdaterAdd.cls
58 lines (44 loc) · 1.46 KB
/
SummaryUpdaterAdd.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "SummaryUpdaterAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
Implements ISummaryUpdater
Private Function ISummaryUpdater_ClearSheet(ws As Worksheet) As Variant
ws.Range("A2:ZZ6000").ClearContents
End Function
Private Function ISummaryUpdater_FitAllColumns(ws As Worksheet) As Variant
ws.Activate
ws.Cells.Select
ws.Cells.EntireColumn.AutoFit
ws.Cells(1, 1).Select
End Function
Private Function ISummaryUpdater_GetVersion() As String
End Function
Private Sub ISummaryUpdater_Update(engine As RuleEngine, sheet As Worksheet)
Dim row As RowInfo
Dim pRule As rule
Dim offset As Integer
Dim r As Range
Dim c As Range
Set r = sheet.Range(sheet.Range("B1"), sheet.Range("B1").End(xlToRight))
'r.Select
offset = 1
' go through all available rules
For Each pRule In engine.rules
sheet.Range("A2").offset(offset - 1, 0) = pRule.Category
For Each row In engine.Rows
If row.Category = pRule.Category Then
For Each c In r
c.offset(offset, 0).Value = c.offset(offset, 0).Value + row.Columns(c.Value)
Next
End If
Next
offset = offset + 1
Next
End Sub