Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
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?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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 05:45 PM.

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

About Us

"It's about Microsoft Excel"