Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Option Explicit
Private MainKeyCol As Long
Private RowCounter As Long
Private Source As Workbook
Private isReadOnly As Boolean
Property Get EOF() As Boolean
If Source.ActiveSheet.Cells(RowCounter, MainKeyCol) = "" Then
EOF = True
EOF = False
End If
End Property
Property Get item(Index As Long) As Range
Set item = Source.ActiveSheet.Cells(RowCounter, Index)
End Property
Property Let item(Index As Long, Value As Variant)
Source.ActiveSheet.Cells(RowCounter, Index).Value = Value
End Property
Property Let StartRow(vs As Long)
RowCounter = vs
End Property
Property Let MainKey(vs As Long)
MainKeyCol = vs
End Property
Public Function NextRecord()
RowCounter = RowCounter + 1
End Function
Public Function PrevRecord()
RowCounter = RowCounter - 1
End Function
Property Let DataSource(ValueWorkbook As Workbook)
Set Source = ValueWorkbook
End Property
Property Get DataSource() As Workbook
Set DataSource = Source
End Property
Property Let ReadOnly(ValueBool As Boolean)
isReadOnly = ValueBool
End Property
Private Sub Class_Initialize()
MainKeyCol = 2
StartRow = 2
isReadOnly = True
End Sub
Public Sub CloseFile(Optional FileName As String = "")
Dim SaveChange As Boolean
If isReadOnly Then
SaveChange = False
Source.SaveAs (FileName)
SaveChange = True
End If
Source.Close SaveChanges:=SaveChange
End Sub
Private Sub Class_Terminate()
Set Source = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment