Move cell focus without activating sheet

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
526
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I'm repeating the first line below several times in order to paste data from multiple sheets into the "template" in my workbook. At the end, the range of cells associated with the last paste will remain selected. Is there a way to deselect that range and/or move the focus to cell A2 without selecting the template sheet? I export the sheet to a separate file and clear the rows that were used at the end of the process but that range remains selected.

VBA Code:
Sheets("S1").Range("A" & lastRow).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False

ThisWorkbook.Sheets("S1").Range("2:" & lastRow).Delete xlUp
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

cortexnotion

Board Regular
Joined
Jan 22, 2020
Messages
136
Office Version
  1. 2013
Platform
  1. Windows
Try...

VBA Code:
Application.CutCopyMode = False
Application.Goto (ThisWorkbook.Sheets("S1").Range("A2"))
 
Solution

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
526
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
It still seems to activate the sheet. I put in another line to reactivate the main sheet. Thanks
 

cortexnotion

Board Regular
Joined
Jan 22, 2020
Messages
136
Office Version
  1. 2013
Platform
  1. Windows
You can change the second line of my suggestion of that is not the sheet you want, I assumed it was A2 on "S1" that you wanted to return to.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,583
Messages
5,597,023
Members
414,116
Latest member
sfullnet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top