I have a template that, using VBA, makes a copy of itself, opens the copy, does a copy/paste-values over the data in each worksheet, and saves that copy. After its done and a user opens the copied file, all the cells on the worksheet are still selected from the Copy method, which I want to avoid. I attempted to add a Activate statement and later a Select statement into the code, but that just results in the always enjoyable "Run-time error 1004 - Select/Activate Method of Range class failed" error. The relevant code looks like this:
I assume that its incorrect to use the Select method inside the With blocks - in fact I thought it was best practice to not use .Select or .Activate at all in my code - but I don't know any other method to unselect ever single cell within my copied file. Can anyone help?
With wb For each ws in .Worksheets With ws .Cells.Copy .Cells.PasteSpecial Paste:=3 Application.CutCopyMode = False .Cells(7, 6).Select <---- Runtime Error End With Next ws End With