Автор: AndVGri
Дата сообщения: 02.05.2007 18:15
NugnaPomosh
Эх, грешник
[more]
Код для кнопки
Код:
Dim pSource As Worksheet, pDest As Worksheet
Dim i As Long, vFirst As Long, vLast As Long, vFirstCol As Long
Dim vBegin As Integer, vEnd As Integer, vCode As Long
Dim vCurrent As Integer, vPos As Long
vBegin = Year(CDate(TextBeginYear.Text))
vEnd = Year(CDate(TextEndYear.Text))
vCode = CLng(TextCode.Text)
Set pSource = ActiveSheet
vFirst = pSource.UsedRange.Row
vFirstCol = pSource.UsedRange.Column
Set pDest = Worksheets.Add
pSource.Activate
pSource.Range(Cells(vFirst, vFirstCol), _
Cells(vFirst, vFirstCol + 2&)).Copy pDest.Cells(1&, 1&)
vLast = pSource.UsedRange.Rows.Count + vFirst - 1&
vFirst = vFirst + 1&: vPos = 1&
For i = vFirst To vLast
vCurrent = Year(CDate(pSource.Cells(i, vFirstCol + 1&).Value))
If (vCurrent >= vBegin) And (vCurrent <= vEnd) And _
(vCode = CLng(pSource.Cells(i, vFirstCol + 2&).Value)) Then
vPos = vPos + 1&
pSource.Range(Cells(i, vFirstCol), _
Cells(i, vFirstCol + 2&)).Copy pDest.Cells(vPos, 1&)
End If
Next i