Copy with Ctrl + C and paste with Ctrl + V in locked sheet

Nikko

Board Regular
Joined
Nov 26, 2018
Messages
73
Copy with Ctrl + C and paste Ctrl + V in the same locked sheet, in certain cells.
Copy with Ctrl + C cell range "R4: R18" and paste in the cell range "N4: N18" with Ctrl + V. How can I do this with VBA code?

Thanks everyone in advance for your time and effort.

Nikko
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Maybe...
VBA Code:
ActiveSheet.Unprotect "your password"
Range("N4:N18").Value = Range("R4:R18").Value
ActiveSheet.Protect "your password"
 
Upvote 0
Hi MARK858,

Thanks for your quick reply & help.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Unprotect ("1234")
If Intersect(Target, Range("R4:R18")) Is Nothing Then Exit Sub
ActiveSheet.ActiveCell.Copy
ActiveSheet.Range("N4:N18").PasteSpecial xlPasteValues
Me.Protect ("1234")
End Sub

I make this code to copy and paste any cells in this Range. The problem with my code is that i copy the cell format.
But want only to copy the values of the cells "R4: R18" and paste them into "N4: N18".
At the same time, as I said before, it just wants to copy & paste selected cells from this area as my code does.

Hope that my English is somewhat understandable :)

Thx,
Nikko
 
Upvote 0
Sry wrong code, now this is the code i make and use, but like i sayd, his copied the format from the cells too, want only values.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Unprotect ("1234")
If Not Intersect(Target, Range("R4:R18", "N4:N18")) Is Nothing Then
Cancel = True
If Application.CutCopyMode Then
.PasteSpecial Paste:=xlValues
    '   .PasteSpecial Paste:=xlFormats
End With
Application.CutCopyMode = False
Else
End If
Me.Protect ("1234")
End If
End Sub
 
Upvote 0
That last code should be pasting nothing, it should be erring out.
 
Upvote 0
A proposed solution how can I do it? :)
Loud code snippets, my little English and my ignorance in VBA, overwhelmed me.
Stand on the hose.
Just want to search for cells in the "R4: R18" area, copy and paste these cell values into the "N4: N18" area (only cell values).
Then the sheet should be locked as before.

any help in this direction is welcome :)

Thx,
Nikko
 
Upvote 0
Just want to search for cells in the "R4: R18" area = Just want select cells (ans olny values of them) from the "R4: R18" area .
 
Upvote 0
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Unprotect "1234"
If Intersect(Target, Range("R4:R18")) Is Nothing Then Exit Sub
Range("N4:N18").Value = Range("R4:R18").Value
Me.Protect "1234"
End Sub
Although I am not sure that you want a Worksheet_SelectionChange, how are you triggering the code? and are you trying to paste a single cell in the range or all 14 cells?
 
Upvote 0
and are you trying to paste a single cell in the range or all 14 cells?
would like to paste single cells or all of them together, or part of them, if necessary.

how are you triggering the code?
Can I trigger this with the right mouse button?
Like that?

VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel As Boolean)
Me.Unprotect "1234"
If Intersect(Target, Range("R4:R18")) Is Nothing Then Exit Sub
Range("N4:N18").Value = Range("R4:R18").Value
Cancel=True
End If
Me.Protect "1234"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,962
Messages
6,122,482
Members
449,088
Latest member
Melvetica

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