```
Option Explicit
Sub collectRows(ByRef CollectedRows As Range, _
AddRange As Range)
If Not CollectedRows Is Nothing Then
Set CollectedRows = Union(CollectedRows, AddRange.EntireRow)
Else
Set CollectedRows = AddRange.EntireRow
End If
End Sub
Sub copyRowsToOtherSheet(RowsRange As Range, _
OtherSheet As Worksheet, _
Optional ByVal LastRowColumnIndex As Variant = 1, _
Optional ByVal FirstRowNumber As Long = 1)
Dim rng As Range
Set rng = OtherSheet.Columns(LastRowColumnIndex) _
.Find(What:="*", _
LookIn:=xlFormulas, _
SearchDirection:=xlPrevious)
If rng Is Nothing Then
Set rng = OtherSheet.Cells(FirstRowNumber, 1)
Else
If rng.Row < FirstRowNumber Then
Set rng = OtherSheet.Cells(FirstRowNumber, 1)
Else
Set rng = OtherSheet.Cells(rng.Row, 1).Offset(1)
End If
End If
RowsRange.Copy rng
End Sub
Function getColumnRange(Sheet As Worksheet, _
Optional ByVal ColumnIndex As Variant = 1, _
Optional ByVal FirstRowNumber As Long = 1) _
As Range
Dim rng As Range
Set rng = Sheet.Columns(ColumnIndex).Find(What:="*", _
LookIn:=xlFormulas, _
SearchDirection:=xlPrevious)
If rng Is Nothing Then Exit Function ' Empty column.
If rng.Row < FirstRowNumber Then Exit Function ' Above FirstRowNumber.
Set getColumnRange = Sheet.Range(Sheet.Cells(FirstRowNumber, ColumnIndex), _
rng)
End Function
```