CheckBox Code to copy & paste range

C

Casey

Mobys of VBA,
I 'm trying to write what I assumed was a simple copy & paste procedur
using a checkbox value as the trigger. I have tried numerous variations
but to no avail. I get no error messages, I also get no desired results
except that everytime I run the code it does unprotect and protect th
worksheet and it always clears the contents of rng2.
The two named ranges (rng1 & rng2) are unprotected and the same siz
and configuration (i.e. A20:A22, A43:A45 respectively) , but they ar
on different sheets. Thanks for any help
Here is my best code to date:

Option Explicit
Private Sub ChkboxRFP_Click()
Dim i As Boolean
Dim rng1 As Range
Dim rng2 As Range

Set rng1 = Sheets("Name Sheet").Range("RFPMsgSource")
Set rng2 = ActiveSheet.Range("RFPMsgDestination")

i = CheckBox1.Value
ActiveSheet.Unprotect ("geekk")

If i = True Then
rng2.ClearContents 'Clear old text
rng1.Copy
rng2.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone
SkipBlanks _
:=False, Transpose:=False
ElseIf i = False Then
rng2.ClearContents
End If

ActiveSheet.Protect ("geekk")
End Su
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top