-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcDataFactory.cls
More file actions
61 lines (52 loc) · 1.8 KB
/
cDataFactory.cls
File metadata and controls
61 lines (52 loc) · 1.8 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
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "cDataFactory"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'**********************************************************
' Class Name: cDataFactory
' Description: Used to Get data to and From cDataTables
' Ability to Load and Save from Excel
'
' Created by: Brendon Raw
' History: v1.00 06 February 2012 - Created
' v1.01 09 February 2012 - Enable ExcludeHeader Row
' References: cDataTable v1.11
'
'
' Instructions: (GetDataTableFromRange) Creates a datatable from a range
' (InsertDataTableToCell) Copys a DataTable with the top left corner in specified cell
'
' TODO: put and retrieve from Recordsets
'*************************************************************************
Public Function GetDataTableFromRange(ByVal rngIN As Object) As cDataTable
On Error GoTo Catch
Dim obj As cDataTable
Dim varArray As Variant
If rngIN.Rows.Count > 1 Then
Set obj = New cDataTable
varArray = rngIN
obj.LoadArray varArray
End If
GoTo Finally:
Catch:
Finally:
Set GetDataTableFromRange = obj
End Function
Public Function InsertDataTableToCell(ByVal rngOUT As Object, objTable As cDataTable, Optional blnExcludeHeader As Variant) As Object
On Error GoTo Catch
Dim rngResized As Object
Set rngResized = rngOUT.Resize(objTable.RecordCount + 1, objTable.DefaultRecord(True).Fields.Count)
If IsMissing(blnExcludeHeader) Then
rngResized = objTable.AsArray
Else
rngResized = objTable.AsArray(blnExcludeHeader)
End If
Catch:
Finally:
Set InsertDataTableToCell = rngResized
End Function