I'm using the below code to find values in cells and then delete the range in-between the found range. My question is does it need to be improved? Specifically, where I set nRow from 1 to 1048576 (the last row address in excel 2007). I don't know this for sure, but it would seem to me that setting 1048576 is a bad practice and there should be a way to set it from 1 to the last address, Thoughts?
Public Sub DeleteAllAppended()
If MsgBox("Are you sure? This will delete every report you have added.", vbOKCancel) = vbCancel Then
Dim nRow As Long
Dim nStart As Long, nEnd As Long
'Figure out where Appened Reports starts.
For nRow = 1 To 1048576
If Range("A" & nRow).Value = "Created by:" Then
nStart = nRow
nStart = nStart + 2
' Figure out where Appened Reports end.
For nRow = nStart To 1048576
If Range("A" & nRow).Value = "Totals" Then
nEnd = nRow
nEnd = nEnd - 1
Range("A" & nStart & ":I" & nEnd).Delete