f you want to copy from cell A2 until the last cell on the worksheet then replace this code with the following code. You might do this if there are headers in the first row.
Cc837974.note(en-us,office.12).gifNote:
If you use this procedure, copy the function RDB_Last into your code module.
First, add this line at the top of the macro.
VB
Dim FirstCell As String
Then add this code.
VB
With mybook.Worksheets(1)
FirstCell = "A2"
Set sourceRange = .Range(FirstCell & ":" & RDB_Last(3, .Cells))
' Test if the row of the last cell is equal to or greater than the row of the first cell.
If RDB_Last(1, .Cells) < .Range(FirstCell).Row Then
Set sourceRange = Nothing
End If
End With
Bookmarks