Home

Copying and pasting a row with muiltiple locked/unlocked fields

%3CLINGO-SUB%20id%3D%22lingo-sub-1074115%22%20slang%3D%22en-US%22%3ECopying%20and%20pasting%20a%20row%20with%20muiltiple%20locked%2Funlocked%20fields%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1074115%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20there%20everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20creating%20a%20costing%20template%20for%20my%20company%20and%20have%20protected%20all%20columns%20that%20include%20a%20formula%2C%20leaving%20columns%20without%20a%20formula%20unprotected%20so%20users%20can%20hard%20key%20in%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPreviously%2C%20I%20just%20had%20the%20cells%20locked%20but%20when%20you%20copied%20and%20pasted%20the%20row%2C%20the%20new%20cells%20were%20unlocked%20and%20therefore%20the%20formulas%20where%20unprotected.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETo%20solve%20this%2C%20I%20instead%20locked%20the%20whole%20column%20with%20formulas%20but%20now%2C%20the%20user%20is%20unable%20to%20copy%20and%20paste%20the%20rows%20at%20all.%20When%20I%20protect%20the%20sheet%2C%20I%20still%20allow%20access%20for%20the%20user%20the%20select%20locked%20objects%20as%20well%20as%20inset%20rows%20so%20I'm%20not%20sure%20where%20the%20block%20is%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F162549i13F8139CABFD108C%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20tips%20or%20tricks%20please%20let%20me%20know!%20I've%20done%20a%20lot%20of%20googling%20to%20try%20and%20resolve%20but%20all%20the%20articles%20I've%20seen%20refer%20to%20vba%20that%20relies%20on%20all%20the%20cells%20being%20locked.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20closest%20thing%20I've%20found%20is%20the%20below%20VBA%20but%20it%20seems%20that%20this%20would%20only%20copy%20and%20paste%20the%20row%20into%20the%20next%20available%20spot%20whereas%20I%20need%20the%20user%20to%20be%20able%20to%20paste%20it%20in%20different%20parts%20of%20the%20document%20(ideally%20where%20they%20could%20select%20the%20row%20they'd%20like%20to%20paste%20after%20and%20the%20VBA%20would%20paste%20below%20that)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20Button1_Click()%3CBR%20%2F%3E'Change%20your%20password%20here%3CBR%20%2F%3ESheets(%22IGP%22).Unprotect%20%22IGP%22%3C%2FP%3E%3CP%3EDim%20Rng%20As%20Long%2C%20i%20As%20Long%3CBR%20%2F%3ERng%20%3D%20Application.InputBox(%22Enter%20number%20of%20rows%20required.%22%2C%20Type%3A%3D1)%3CBR%20%2F%3EFor%20i%20%3D%201%20To%20Rng%3CBR%20%2F%3E'Change%20source%20row%20and%20sheet%20name%3CBR%20%2F%3ERange(%22a9%22).EntireRow.Copy%3CBR%20%2F%3ESheets(%22IGP%22).Range(%22a65536%22).End(xlUp).Offset(1).Insert%20Shift%3A%3DxlDown%3CBR%20%2F%3ENext%20i%3C%2FP%3E%3CP%3EApplication.CutCopyMode%20%3D%20False%3CBR%20%2F%3E'Change%20your%20password%20here%3CBR%20%2F%3ESheets(%22IGP%22).Protect%20%22IGP%22%3C%2FP%3E%3CP%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20so%20much%20in%20advance%20for%20any%20help!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1074115%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
kkayserk
Occasional Visitor

Hi there everyone,

 

I'm creating a costing template for my company and have protected all columns that include a formula, leaving columns without a formula unprotected so users can hard key in data.

 

Previously, I just had the cells locked but when you copied and pasted the row, the new cells were unlocked and therefore the formulas where unprotected.

 

To solve this, I instead locked the whole column with formulas but now, the user is unable to copy and paste the rows at all. When I protect the sheet, I still allow access for the user the select locked objects as well as inset rows so I'm not sure where the block is:

 

clipboard_image_0.png

 

Any tips or tricks please let me know! I've done a lot of googling to try and resolve but all the articles I've seen refer to vba that relies on all the cells being locked. 

 

The closest thing I've found is the below VBA but it seems that this would only copy and paste the row into the next available spot whereas I need the user to be able to paste it in different parts of the document (ideally where they could select the row they'd like to paste after and the VBA would paste below that)

 

Sub Button1_Click()
'Change your password here
Sheets("IGP").Unprotect "IGP"

Dim Rng As Long, i As Long
Rng = Application.InputBox("Enter number of rows required.", Type:=1)
For i = 1 To Rng
'Change source row and sheet name
Range("a9").EntireRow.Copy
Sheets("IGP").Range("a65536").End(xlUp).Offset(1).Insert Shift:=xlDown
Next i

Application.CutCopyMode = False
'Change your password here
Sheets("IGP").Protect "IGP"

End Sub

 

Thanks so much in advance for any help!

 

Related Conversations