This code works great and is called in the Print code, but I can't figure how to then Save and Close this workbook. The Inventory workbook Saves and Closes itself with Worksheet_Change code, but this workbook just sticks at the last direction given before opening the Inventory file. If there is no solution, I will use a button to Save and Close, which works fine but I know will cause files to be left open and confuse users (mostly farm laborers). I have tried several ideas, such as Exit Sub and adding a separate macro that, in order, calls CopyAndPasteToTracking then SaveAndClose. I think that the End Sub command is being ignored because I can get no other code to execute after the last line before End Sub (except for using button to run another macro). This is the end of a volunteer project I started in 2017 and had never used VBA before, so I am very appreciative of the help y'all have given me over the years, not only directly through stackoverflow but also as a wonderful reference. Anyway, this is my last weird issue that online research or looking through my books doesn't address, so I sure hope that someone knows an answer.
Sub CopyPasteToTracking()
Sheets("Export Table").Select
Range("$A$1:$K$" & Range("M1")).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sales Record").Select
Range("$A$10").Select
Workbooks.Open Filename:= _
"C:\Users\Michelle\Documents\Maple Inventory System\YYYY\YYYY SYRUP MANAGEMENT\test
YYYY SYRUP INVENTORY TRACKING.xlsm"
ActiveWindow.ScrollWorkbookTabs Sheets:=5
Sheets("Sales").Select
Range("$B$" & (1 + Range("Y1"))).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
End Sub
In case it helps to know, I also tried adding ThisWorkbook.Save and ThisWorkbook.Close after the command in Print procedure to call the macro and it didn't do either action.