Forum Discussion
Macro only run once
joh532485 OK I don't want to parse out all that your macro does because it is rather messy and i could probably spend a lot time to clean it up but may not even matter to you. that said here is what I think you need to fix the 1st macro. the 2nd macro that deletes the sheet and most of the data you could do something but I fear it is risky because it could easily delete the wrong sheet. Why not just lock the file and make it read only so they open it, make changes and have to Save As, or not, and then when they close it and re-open it as a clean workbook.
Sub Macro3()
'
' Macro3 Macro
'
' Keyboard Shortcut: Ctrl+q
'
dim wsNew as Worksheet
Range("A6").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlDown)).Select
...
Range("A6").Select
Application.CutCopyMode = False
set wsNew = Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"Sheet1!R6C1:R37C69", Version:=6).CreatePivotTable TableDestination:= _
wsNew.name &"!R3C1", TableName:="PivotTable1", DefaultVersion:=6
wsNew.Select