Move cell focus without activating sheet

KGee

Well-known Member
Joined
Nov 26, 2008
Messages
537
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
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Try...

VBA Code:
Application.CutCopyMode = False
Application.Goto (ThisWorkbook.Sheets("S1").Range("A2"))
 
Upvote 0
Solution
It still seems to activate the sheet. I put in another line to reactivate the main sheet. Thanks
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,738
Members
448,988
Latest member
BB_Unlv

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
Back
Top