VBA code(s) for 1st sheet to COPY with single click, and 2nd one to PASTE with single click

tasic89

New Member
Joined
Apr 12, 2021
Messages
35
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
Title says it all.. I found one code for pasting only values with a click

Excel Formula:
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    On Error Resume Next
    Target.PasteSpecial xlPasteValues
    Application.CutCopyMode = True
End Sub

Other code is for copy with just a click on desired cell


Excel Formula:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Not Intersect(Target, Range("xxxx")) Is Nothing Then
        Target.Copy
    End If
End Sub

*xxx is single cell or a range.

But if I apply those two codes, my Excel is glitching until "out of space stack" error comes out.

Is there any way for this to work for 2 different sheets (one have cell which is concatenating two cells, and than i want that result pasted in second sheet)
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Remove the first sub from the workbook code and put it in the Worksheet_selectionchange module of the worksheet where you want the result pasted. NOT the worksheet with the second routine
 
Upvote 0

Forum statistics

Threads
1,214,899
Messages
6,122,155
Members
449,068
Latest member
shiz11713

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