VERSION 1.0 CLASS BEGIN MultiUse = -1 'True END Attribute VB_Name = "IteratorWork" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = False Option Explicit Public row_ As Long Private data_ As Excel.Worksheet Public Sub Init(target As Excel.Worksheet, Optional tRow& = WORKER_FIRST_ROW) Set data_ = target row_ = tRow Call SkipFillers End Sub Private Function SkipFillers() Do If data_.Cells(row_, S_W_DATE) = vbNullString Then _ Exit Function If VBA.IsDate(data_.Cells(row_, S_W_DATE)) Then _ Exit Function row_ = row_ + 1 Loop End Function Public Function Increment() row_ = row_ + 1 Call SkipFillers End Function Public Function GoFirst() row_ = WORKER_FIRST_ROW Call SkipFillers End Function Public Function GoLast() row_ = data_.Columns(S_W_DATE).Find(vbNullString, LookAt:=xlWhole).Row - 1 End Function Public Function GoUntil(nTargetDate&) Do While Not IsDone And DDate < nTargetDate Call Increment Loop End Function Public Function IsDone() As Boolean IsDone = data_.Cells(row_, S_W_DATE) = vbNullString End Function Public Function IsMergedDescription() As Boolean IsMergedDescription = False Dim iDescription As Excel.Range: Set iDescription = data_.Cells(row_, S_W_CONTENTS) If Not iDescription.MergeCells Then _ Exit Function IsMergedDescription = iDescription.MergeArea.Cells(1, 1).Row <> row_ End Function Public Function RemoveRow() Call data_.Rows(row_).Delete End Function Public Function AddYear(nYear%) data_.Rows(row_).OutlineLevel = 1 data_.Cells(row_, S_W_DATE) = Fmt("ÃÎÄ: {1}", nYear) Call Increment End Function Public Function AddMonth(nMonth%) data_.Rows(row_).OutlineLevel = 2 data_.Cells(row_, S_W_DATE) = Fmt("Ìåñÿö: {1}", VBA.MonthName(nMonth)) Call Increment End Function Public Function AddDay(nDate&, bIsHoliday As Boolean) data_.Rows(row_).OutlineLevel = 3 DDate = nDate WorkType = WORK_DEFAULT Duration = 0 Project = IIf(bIsHoliday, PROJECT_HOLIDAYS, PROJECT_MISSING) Call Increment End Function '===== Propertiy Get ===== Public Property Get DDate() As Long DDate = data_.Cells(row_, S_W_DATE) End Property Public Property Get Project() As String Project = data_.Cells(row_, S_W_PROJECT) End Property Public Property Get Duration() As Double Duration = data_.Cells(row_, S_W_HOURS) End Property Public Property Get WorkType() As String WorkType = data_.Cells(row_, S_W_TYPE) End Property Public Property Get Description() As String If Not IsMergedDescription Then Description = data_.Cells(row_, S_W_CONTENTS) Else Description = data_.Cells(row_, S_W_CONTENTS).MergeArea.Cells(1, 1) End If End Property ' ==== Property Let ==== Public Property Let DDate(newVal&) data_.Cells(row_, S_W_DATE) = newVal End Property Public Property Let Project(newVal$) data_.Cells(row_, S_W_PROJECT) = newVal End Property Public Property Let Duration(newVal As Double) data_.Cells(row_, S_W_HOURS) = newVal End Property Public Property Let WorkType(newVal$) data_.Cells(row_, S_W_TYPE) = newVal End Property Public Property Let Description(newVal$) data_.Cells(row_, S_W_CONTENTS) = newVal End Property