hello, I did not test this code but maybe this can help?
To make sure your macro always references the correct worksheet, you will need to fully qualify the worksheet references in your code. This means that, whenever you reference a worksheet or range in your code, you should include the workbook and worksheet name, as well as the cell or range reference. For example, instead of using Range("A1"), you would use something like ThisWorkbook.Worksheets("Sheet1").Range("A1"). This tells Excel to use the range "A1" on the "Sheet1" worksheet in the active workbook.
Another approach you could use is to create a variable to store a reference to the new worksheet. You could then use this variable throughout your code to reference the correct worksheet. For example:
By using a variable to store the reference to the new worksheet, you can avoid any confusion about which worksheet your code is referencing.
Bookmarks