whitebutterfly000
New Member
- Joined
- May 20, 2023
- Messages
- 1
- Office Version
- 2019
- 2016
- Platform
- Windows
Hello all,
Hope you can answer me I have been trying to add
(clearcontents) to the code below that I have to copy from all sheets , clearcontents in master sheet before paste then paste , and everytime I am getting an error.
to sum up what Im trying to do, copy contents from all sheets I have in this workbook and paste in in the ARCHIVE sheet, and everytime it pastes I want it to clear contents on the ARCHIVE sheet then paste so that it updates in stead of duplicating value.
Im gonna post my code here if anyone can tell me where to put it please.
Hope you can answer me I have been trying to add
(clearcontents) to the code below that I have to copy from all sheets , clearcontents in master sheet before paste then paste , and everytime I am getting an error.
to sum up what Im trying to do, copy contents from all sheets I have in this workbook and paste in in the ARCHIVE sheet, and everytime it pastes I want it to clear contents on the ARCHIVE sheet then paste so that it updates in stead of duplicating value.
VBA Code:
Sub CopyToMaster()
ShtCount = ActiveWorkbook.Sheets.Count
For I = 2 To ShtCount
Worksheets(I).Activate
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Range("a2:N" & LastRow).Select
Selection.Copy
Sheets("ARCHIVE").Activate
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Select
'Required after first paste to shift active cell down one
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
ActiveCell.Offset(0, 0).Select
Selection.PasteSpecial
ActiveWorkbook.Save
Next I
End Sub
Sub M()
Application.OnTime Now + TimeValue("00:00:10"), "CopyToMaster"
End Sub
Im gonna post my code here if anyone can tell me where to put it please.