View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
brad brad is offline
external usenet poster
 
Posts: 32
Default Selecting only locked cells

Might be another way but:

Dim rng As Range
Set rng = ActiveSheet.UsedRange

Dim rngLockedCells As Range
Dim cell As Range
For Each cell In rng
If cell.Locked = True Then
If rngLockedCells Is Nothing Then
Set rngLockedCells = cell
Else
Set rngLockedCells = Union(rngLockedCells,
cell)
End If
End If
Next
rngLockedCells.Select

HTH.

-Brad
-----Original Message-----
Hi

I want to be able to set a range variable equal to the

cells in a Worksheet
which are locked. I will be using visual basic code.

I have looked at xlspecialcells but with no luck.

Tim






.