I am trying to create an archive option for some manual inputs. I had that working, but when archive was hidden, then I experienced some issues.
Sub Archive()
Dim sDumpRange As String
Dim sDumpSheet As String
sDumpSheet = "Active archive"
If Range("C6") <> Empty Then
pRow = Sheets(sDumpSheet).Range("I1")
If pRow > 1 Then
Range("A2:E" & pRow).Delete Shift:=xlUp
Else
End If
sDumpRange = "'" & Sheets("Active archive") & "'!" & "A" & Range("A5000").End(xlUp).Row + 1
' sDumpRange = "A" & Range("A5000").End(xlUp).Row + 1
Sheets("call-outs completed").Range("a10:e109").Copy
Worksheets(sDumpSheet).Range(sDumpRange).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("call-outs completed").Range("a10:a109").ClearContents
Sheets("call-outs completed").Select
Range("A11").Select
Else
MsgBox "Data not archived. Please select your name first and try again."
End If
End Sub
There is one cell counting how many rows are with older date than 2 months and then that old data is being purged (delete section with pRow).
I was trying different things, and now sDumpRange
was modified and it is not working, but when it was, it looked like that was calculating the range in the wrong, data input sheet. That was ten being copied to archive from the wrong cell (Active Archive A11). And when refreshed, then data was overwritten as Input sheet is also being cleared.
The key seems to be within sDumpRange
calculation now.