[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

Macro Pastes to Cell with focus

Excel VBA Macro is pasting to the cell with focus rather than
the Cell selected. I need it pasted to cell B15. How do I overcome a user changing focus
Worksheets(1).Activate
   Cells(15, 2).Select
   ThisWorkbook.Sheets(1).Paste

Open in new window

0
llawrenceg
Asked:
llawrenceg
  • 2
1 Solution
 
AlanConsultantCommented:
Try this (substituting for your code fragment):

   ThisWorkbook.Sheets(1).Cells(15, 2).Paste

Open in new window


Alan.
0
 
AlanConsultantCommented:
Sorry, forgot to amend the end too:

  ThisWorkbook.Sheets(1).Cells(15, 2).PasteSpecial xlPasteValues

Open in new window


Alan.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now