Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Excel problem

Thread Tools
 
Search this Thread
 
Old 10 August 2007, 08:43 AM
  #1  
bigsinky
Scooby Regular
Thread Starter
 
bigsinky's Avatar
 
Join Date: Dec 2002
Location: Sunny BELFAST
Posts: 19,408
Likes: 0
Received 0 Likes on 0 Posts
Default 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
Old 10 August 2007, 09:20 AM
  #2  
ChefDude
Scooby Regular
 
ChefDude's Avatar
 
Join Date: Aug 2005
Posts: 4,290
Likes: 0
Received 0 Likes on 0 Posts
Default

not without using vba
Old 10 August 2007, 11:18 AM
  #3  
bigsinky
Scooby Regular
Thread Starter
 
bigsinky's Avatar
 
Join Date: Dec 2002
Location: Sunny BELFAST
Posts: 19,408
Likes: 0
Received 0 Likes on 0 Posts
Default

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
Old 14 August 2007, 02:10 PM
  #4  
michaelro
Scooby Regular
 
michaelro's Avatar
 
Join Date: Jan 2006
Posts: 897
Likes: 0
Received 0 Likes on 0 Posts
Default

Not ideal but should do what you are after.
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
Related Topics
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
leg200
Subaru Parts
5
07 October 2015 07:31 AM
has-scooby
Subaru Parts
4
06 October 2015 03:47 PM
bluebullet29
General Technical
9
05 October 2015 02:17 PM



Quick Reply: Excel problem



All times are GMT +1. The time now is 08:35 AM.