VBA code in excel
Solved/Closed
Related:
- VBA code in excel
- Battery reset code - Guide
- Number to words in excel formula without vba - Guide
- Samsung volume increase code - Guide
- How to get whatsapp verification code online - Guide
- Vba case like - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Jan 23, 2012 at 09:06 AM
Jan 23, 2012 at 09:06 AM
Hi Issa,
For the following code to work, you need to make some changes to your sheet.
Delete the "Allow user to edit range".
Now select the ranges you want users to be able to adjust (P11:P20,R11:X20).
Right-click, cell properties, protection tab and uncheck protection.
Goto topmenu, extra, protection, protect sheet.
Now you basicly got what you already had.
Now right-click the sheets tab and select view code.
Paste the following code:
Now test the result by changing the value of range R11:R20 from 1 or 2 to 3 or 4 and back.
Will this work for you?
Best regards,
Trowa
For the following code to work, you need to make some changes to your sheet.
Delete the "Allow user to edit range".
Now select the ranges you want users to be able to adjust (P11:P20,R11:X20).
Right-click, cell properties, protection tab and uncheck protection.
Goto topmenu, extra, protection, protect sheet.
Now you basicly got what you already had.
Now right-click the sheets tab and select view code.
Paste the following code:
Private Sub Worksheet_Change(ByVal Target As Range) Dim cRow As Integer If Intersect(Target, Range("R11:R20")) Is Nothing Then Exit Sub If Target.Value = 3 Or Target.Value = 4 Then ActiveSheet.Unprotect cRow = Target.Row Range(Cells(cRow, "T"), Cells(cRow, "U")).Locked = True ActiveSheet.Protect End If If Target.Value = 1 Or Target.Value = 2 Then ActiveSheet.Unprotect cRow = Target.Row Range(Cells(cRow, "T"), Cells(cRow, "U")).Locked = False ActiveSheet.Protect End If End Sub
Now test the result by changing the value of range R11:R20 from 1 or 2 to 3 or 4 and back.
Will this work for you?
Best regards,
Trowa
Jan 24, 2012 at 12:13 PM
Thanks a lot, I appreciate all your assistance.
It workes excellent, great :)
Thank you again.