I'm very new to VBA and have put together a macro that currently does exactly what I want: copy cells from one worksheet to another, clear the cells copied, refresh my pivot tables and save the file.
Here is what I am using for it:
Sub Copyinfo()
On Error GoTo Err_Execute
Sheet1.Range("A17:R17").Copy
Sheet2.Range("A2").Rows("2:2").Insert shift:=xlDown
Sheet2.Range("A2").Rows("2:2").PasteSpecial Paste:=xlPasteValuesAndNumberFormats
Sheet1.Range("C5:I16, Q5:R5").ClearContents
Err_Execute:
If Err.Number = 0 Then MsgBox "Copied Data", vbInformation Else _
MsgBox Err.Description
ThisWorkbook.RefreshAll
ThisWorkbook.Save
End Sub
What I want to know is whether this macro will be stable as I continue to add lines of data to it in the future. Essentially I want to minimize the risk of the file crashing or my data being erased. Otherwise, would anyone have any suggestions to offer me to improve this? Thank you.