PDA

View Full Version : Protect cells at different intervals and allow to select certain range



marreco
08-16-2012, 05:12 PM
When I need to run my macro ...

I need to protect the line 'A1: M1' (but NOT the cells might be selected).

I need to protect and range 'A2: M65536' (however this interval I have to select the cells to be able to copy them).

Thank you!!

CatDaddy
08-17-2012, 10:14 AM
ActiveSheet.Unprotect
Range("A1:M" & Rows.Count).Locked = True
ActiveSheet.protect Contents:=True

marreco
08-17-2012, 10:37 AM
Hi
Thanks for replying but where do I put the code?
Private Sub txtData_Change()
ActiveSheet.Unprotect "123" '<--CatDaddy, I would have to replace this line for its macro
If Txtdata.Text <> "" And IsDate(Txtdata.Text) And IsDate(TxtAte.Text) Then
Selection.AutoFilter Field:=7, Criteria1:=">=" & Format(Txtdata.Text, "mm/dd/yyyy"), Operator:=xlAnd, Criteria2:="<=" & Format(TxtAte.Text, "mm/dd/yyyy")
Else
Selection.AutoFilter Field:=7
End If
ActiveSheet.Protect "123" '<--CatDaddy, I would have to replace this line for its macro
End SubThank you!!!

CatDaddy
08-17-2012, 02:48 PM
Private Sub txtData_Change()
ActiveSheet.Unprotect "123" '<--CatDaddy, I would have to replace this line for its macro
If Txtdata.Text <> "" And IsDate(Txtdata.Text) And IsDate(TxtAte.Text) Then
Selection.AutoFilter Field:=7, Criteria1:=">=" & Format(Txtdata.Text, "mm/dd/yyyy"), Operator:=xlAnd, Criteria2:="<=" & Format(TxtAte.Text, "mm/dd/yyyy")
Else
Selection.AutoFilter Field:=7
End If
Range("A1:M" & Rows.Count).Locked = True
ActiveSheet.Protect "123" '<--CatDaddy, I would have to replace this line for its macro
End Sub

marreco
08-18-2012, 06:36 AM
Hi.
I need to make a note of course I had not mentioned!

I need to line 1 ("A1: M1") and Column 'L' totaalmente be blocked (NOT allow select cells or range).

Now 'A2: M65536' allow copying and celecionar céluals or range.

Can you help me with this my code posted above?

Thank you!!

marreco
08-21-2012, 03:28 AM
Hi.

Any idea?

thank you!!

CatDaddy
08-21-2012, 08:54 AM
I dont know as far as I can tell you are looking for the EnableSelection property but it seems like you can only make it so either all of the locked cells cannot be selected or all of them can, and you are looking to lock multiple cells but only block a few from selection correct? hopefully someone else has seen this before

marreco
08-21-2012, 04:26 PM
Hi.
I thought there was an option to completely block a range.:(

while another range, i could select feathers, and not change the data ..

thank you!