Excel problem
#1
Scooby Regular
Thread Starter
Join Date: Dec 2002
Location: Sunny BELFAST
Posts: 19,408
Likes: 0
Received 0 Likes
on
0 Posts
Excel problem
If a certain cell contains a word can i lock other cells for editing based on that condition? any excel gurus out there that can solve my problem.
TIA
Sinky
TIA
Sinky
#3
Scooby Regular
Thread Starter
Join Date: Dec 2002
Location: Sunny BELFAST
Posts: 19,408
Likes: 0
Received 0 Likes
on
0 Posts
any VBA experts out there. I need this spreadsheet to be idiot proof. the jist is if a certain cell contain something i need 3 columns locked for editing while if it contains something else i need 2 columns locked for editing.
Hope someone can help me
TIA
Sinky
Hope someone can help me
TIA
Sinky
#4
Not ideal but should do what you are after.
Right click on the sheet tab and select view code - Then paste the following:
Right click on the sheet tab and select view code - Then paste the following:
Code:
Private Sub Worksheet_Change(ByVal Target As Range) Const strPassword As String = "Password" 'Change this as necessary 'This macro assumes you will want to allow users to edit the 3 columns if the cell doesn't 'contain either of the two specified values (If not remove code specified below) 'A Worksheet will start out with Locked highlighted for everycell 'This needs to be removed first Manually - Select all cells, Properties, Uncheck Locked 'Check which cell has been changed (the one containing the value which will lock/unlock columns If Target.Address = "$A$1" Then 'If Cell = Value to Lock 3 Columns If Target.Value = "Value to Lock 3 Columns" Then 'Change as Necessary 'Unprotect Worksheet ActiveSheet.Unprotect Password:=strPassword 'UnLock 3 Columns then relock Range("B:D").Locked = False Range("B:D").Locked = True 'Protect Worksheet ActiveSheet.Protect Password:=strPassword 'Otherwise if cell = Value to Lock 2 Columns ElseIf Target.Value = "Value to Lock 2 Columns" Then 'Change as necessary 'Unprotect Worksheet ActiveSheet.Unprotect Password:=strPassword 'UnLock 2 Columns then relock Range("B:D").Locked = False Range("B:C").Locked = True 'Protect Worksheet ActiveSheet.Protect Password:=strPassword 'Otherwise if Cell = Anything Else Else 'Unprotect Worksheet 'Remove if required ActiveSheet.Unprotect Password:=strPassword 'Remove if required 'UnLock 3 Columns 'Remove if required Range("B:D").Locked = False 'Remove if required 'Protect Worksheet 'Remove if required ActiveSheet.Protect Password:=strPassword 'Remove if required End If Else End If End Sub
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
bluebullet29
General Technical
9
05 October 2015 02:17 PM