Pasting into protected cells

A

Alfred

Is it possible to "protect" cells in a row such that when you are
pasting a group of cells into that row, the protected cells are
skipped over?

Example:

I want to paste this:
Columns
A B C
d1 d2 d3

into this:
Columns
A B C
p

p="protected" cell


so it looks like this:
Columns
A B C
d1 p d3


Is this possible with Excel as it is? With a script or macro?

Thanks!
 
P

Paul C

I think you would have to go the macro route and check each cell.

This sample uses the Locked/Unlocked Status of the target cell as the
trigger. If the sheet is protected, it will need to be unprotected first.

Sheets("Sheet2").unprotect password:="Password"
If no password is used you dont need the password part.

To protect use
Sheets("Sheet2").protect password:="Password"

You may want to use the macro recorder to get the exact code for all of your
particular protection options. The recorded will not capture the password
entry and you will have to add that manually.

Sub pasteonlyopen ()
'UNPROTECT HERE IF NEEDED
For C=1 to 3

If Sheets("Sheet2").cells (1,C).locked=false then
Sheets("Sheet2").cells(1,C)=Sheets("Sheet1").cells(1,C)
Else
Sheets("Sheet2").cells(1,C)="P"
End If
Next C
'REPROTECT HERE
End Sub
 

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