PDA

View Full Version : Solved: Protect cells on sheet to last row without protecting sheet



BillyH
02-27-2012, 04:39 AM
Hi,
Please can someone assist.

Found the attached in the forum under which works great for a defined range If Not Intersect(Target, Range("A1")) Is Nothing Then (Code Under Sheet1)

I would like to change this to look at the last row in a column e.g
If Not Intersect(Target, Range("A1:F" and Last_Row)) Is Nothing Then

but where do I place the :dunno
Last_Row = Sheets("Sheet1").UsedRange.Rows.Count
to define the last row

Thanks BillyH

BillyH
02-27-2012, 06:21 AM
:hi: Change the following Sub to
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Sh As Worksheet
Dim Last_Row As Long

For Each Sh In Sheets
Last_Row = Sheets("Sheet1").UsedRange.Rows.Count
Next Sh
If Not Intersect(Target, Range("A1:F" & Last_Row)) Is Nothing Then '''sets which cell(s) to work with
''Use the above line to set a range of cells by changing ("A1") to your range = Range("A1:F" & Last_Row)) Cell A1 to the last row in Col F