-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCAssetManager.cls
More file actions
184 lines (144 loc) · 5.16 KB
/
CAssetManager.cls
File metadata and controls
184 lines (144 loc) · 5.16 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "CeamData"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'### Private instance variables ###
Private pManualActivities() As Variant
Private pAssetCategories() As Variant
Private pAssetTypes() As Variant
Private pAssetOwners() As Variant
Private pVirtualAssets() As Variant
Private pAllAssets() As Variant
'### Getter Properties ###
Public Property Get ManualActivities() As Variant
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets("Lookups")
Dim lookupColumn As String
Dim lookupColumnBaseCell As String
Dim lookupColumnRange As String
lookupColumn = "T"
lookupColumnBaseCell = lookupColumn & "2"
lookupColumnRange = lookupColumn & ":" & lookupColumn
Dim columnCount As Integer
columnCount = WorksheetFunction.CountA(wks.Range(lookupColumnRange)) - 1
ReDim pManualActivities(columnCount)
For i = 0 To columnCount
pManualActivities(i) = Range(lookupColumnBaseCell).Offset(i)
Next
ManualActivities = pManualActivities
End Property
Public Property Get AssetCategories() As Variant
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets("Lookups")
Dim lookupColumn As String
Dim lookupColumnBaseCell As String
Dim lookupColumnRange As String
lookupColumn = "A"
lookupColumnBaseCell = lookupColumn & "2"
lookupColumnRange = lookupColumn & ":" & lookupColumn
Dim columnCount As Integer
columnCount = WorksheetFunction.CountA(wks.Range(lookupColumnRange)) - 1
ReDim pAssetCategories(columnCount)
For i = 0 To columnCount
pAssetCategories(i) = Range(lookupColumnBaseCell).Offset(i)
Next
AssetCategories = pAssetCategories
End Property
Public Property Get AssetTypes() As Variant
ReDim pAssetTypes(1)
pAssetTypes(0) = "Capital"
pAssetTypes(1) = "Rebuildable"
AssetTypes = pAssetTypes
End Property
Public Property Get AssetOwners() As Variant
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets("Lookups")
Dim lookupColumn As String
Dim lookupColumnBaseCell As String
Dim lookupColumnRange As String
lookupColumn = "B"
lookupColumnBaseCell = lookupColumn & "2"
lookupColumnRange = lookupColumn & ":" & lookupColumn
Dim columnCount As Integer
columnCount = WorksheetFunction.CountA(wks.Range(lookupColumnRange)) - 1
ReDim pAssetOwners(columnCount, 1)
For i = 0 To columnCount
pAssetOwners(i, 0) = Range(lookupColumnBaseCell).Offset(i, 0)
pAssetOwners(i, 1) = Range(lookupColumnBaseCell).Offset(i, 1)
Next
AssetOwners = pAssetOwners
End Property
Public Property Get VirtualAssets() As Variant
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets("Lookups")
Dim lookupColumn As String
Dim lookupColumnBaseCell As String
Dim lookupColumnRange As String
lookupColumn = "D"
lookupColumnBaseCell = lookupColumn & "2"
lookupColumnRange = lookupColumn & ":" & lookupColumn
Dim columnCount As Integer
columnCount = WorksheetFunction.CountA(wks.Range(lookupColumnRange)) - 1
ReDim pVirtualAssets(columnCount, 1)
For i = 0 To columnCount
pVirtualAssets(i, 0) = Range(lookupColumnBaseCell).Offset(i, 0)
pVirtualAssets(i, 1) = Range(lookupColumnBaseCell).Offset(i, 1)
Next
VirtualAssets = pVirtualAssets
End Property
Public Property Get AllAssets() As Variant
Dim wks As Worksheet
Set wks = ThisWorkbook.Worksheets("ASSETS")
Dim lookupColumn As String
Dim lookupColumnBaseCell As String
Dim lookupColumnRange As String
lookupColumn = "A"
lookupColumnBaseCell = lookupColumn & "2"
lookupColumnRange = lookupColumn & ":" & lookupColumn
Dim columnCount As Integer
columnCount = WorksheetFunction.CountA(wks.Range(lookupColumnRange)) - 1
ReDim pAllAssets(columnCount, 4)
For i = 0 To columnCount
For j = 0 To 4
pAllAssets(i, j) = wks.Range(lookupColumnBaseCell).Offset(i, j)
Next
Next
AllAssets = pAllAssets
End Property
Function allAssetsForAssetGroup(AssetGroup As String) As Variant
'Dim pAllAssetsForAssetGroup() As Variant
Dim relevantRowNumbers() As Variant
Dim tempAllAssets() As Variant
tempAllAssets = Me.AllAssets
Dim counter As Integer
counter = 0
'get the row numbers that match
For i = 0 To UBound(tempAllAssets)
If (tempAllAssets(i, 0) = AssetGroup) Then
ReDim Preserve relevantRowNumbers(counter)
relevantRowNumbers(counter) = i
counter = counter + 1
End If
Next
'load matched rows into new pallassets array
If (counter) Then
ReDim pAllAssetsForAssetGroup(UBound(relevantRowNumbers), 4)
For k = 0 To UBound(relevantRowNumbers)
For j = 0 To 4
pAllAssetsForAssetGroup(k, j) = tempAllAssets(relevantRowNumbers(k), j)
Next
Next
Else
ReDim pAllAssetsForAssetGroup(0, 4)
End If
allAssetsForAssetGroup = pAllAssetsForAssetGroup
End Function
Sub xmlTest()
Dim xmlObject As MSXML2.DOMDocument60
Set xmlObject = New MSXML2.DOMDocument60
End Sub