A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Lock Row (A~F) based on criteria in g



 
 
Thread Tools Display Modes
  #1  
Old July 14th 12, 10:48 AM
nhkhurum nhkhurum is offline
Junior Member
 
First recorded activity by ExcelBanter: Jul 2012
Posts: 1
Default Lock Row (A~F) based on criteria in g

I have lot of data in sheet 1 (for whole years) I want to lock cell from A~F when in cell G i give some criteria Like Posted. Whole the sheet remain unprotected.

Regards

Noor
Ads
  #2  
Old July 14th 12, 07:00 PM posted to microsoft.public.excel.programming
Auric__
external usenet poster
 
Posts: 304
Default Lock Row (A~F) based on criteria in g

nhkhurum wrote:

> I have lot of data in sheet 1 (for whole years) I want to lock cell from
> A~F when in cell G i give some criteria Like Posted. Whole the sheet
> remain unprotected.


To lock all of the cells in A:F in the current row based on the contents of G
[current row], it's like this:

Sub lockWhenCriteriaMet1()
Dim cell As Range
For Each cell In Range("G:G")
If cell.Value = criteria Then
Range("A" & cell.Row & ":F" & cell.Row).Locked = True
End If
Next
End Sub

If the cells are locked individually, based on G, then it's more like this:

Sub lockWhenCriteriaMet2()
Dim cell As Range
For Each cell In Range("G:G")
Select Case cell.Value
Case criteria_A
Cells(cell.Row, 1).Locked = True
Case criteria_B
Cells(cell.Row, 2).Locked = True
'etc...
End Select
Next
End Sub

--
Sacrificing minions: is there any problem it CAN'T solve?
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Query criteria based on a changing criteria list bwilk77 Excel Discussion (Misc queries) 2 May 27th 09 04:03 PM
Need to lock data based on '=today()' value D Patel[_2_] Excel Programming 0 March 3rd 08 09:10 PM
lock cells based on formula MIke Excel Programming 4 November 15th 07 07:31 PM
lock cell based on a condition Amanda Excel Worksheet Functions 22 June 25th 07 07:53 PM
How to lock a row in a spreadsheet based on the value in a cell Prasad Excel Worksheet Functions 3 December 16th 05 05:18 PM


All times are GMT +1. The time now is 06:52 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Copyright ©2004-2013 ExcelBanter.
The comments are property of their posters.