ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Pasting into protected cells (https://www.excelbanter.com/excel-worksheet-functions/249200-pasting-into-protected-cells.html)

Alfred

Pasting into protected cells
 
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!


Paul C

Pasting into protected cells
 
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
--
If this helps, please remember to click yes.


"Alfred" wrote:

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!

.



All times are GMT +1. The time now is 05:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com