Hi again
So I have the first part of the code working to refresh all tables. Now I am trying to also copy a range of cells and paste to a location on the same sheet I am leaving or deactivation (that is, the Forecast sheet). The copy, paste code works as a regular macro, but when included in the Worksheet, I am unable to navigate away from the sheet. It just keeps taking me back to Forecast.
I need both to happen every time I leave the Forecast sheet. I have tried several variation to no avail.
Any suggestions are welcome
and thanks in advance
Vonda
So I have the first part of the code working to refresh all tables. Now I am trying to also copy a range of cells and paste to a location on the same sheet I am leaving or deactivation (that is, the Forecast sheet). The copy, paste code works as a regular macro, but when included in the Worksheet, I am unable to navigate away from the sheet. It just keeps taking me back to Forecast.
I need both to happen every time I leave the Forecast sheet. I have tried several variation to no avail.
Any suggestions are welcome
and thanks in advance
Vonda
Code:
Private Sub Worksheet_Deactivate()
Application.ScreenUpdating = False
ThisWorkbook.RefreshAll
If hasRun Then Exit Sub
Application.ScreenUpdating = False
Application.CutCopyMode = False
Sheets("Forecast").Select
Range("OI12:PV12").Select
Selection.Copy
Sheets("Forecast").Select
Cells(Range("oj11").Value, "OI").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
hasRun = True
Application.CutCopyMode = True
Application.ScreenUpdating = True
End Sub