Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default Searching for locked/unlocked cells

Hi All

I have a spreadsheet which has many cells locked, and they are spread
all across my worksheet.

I want a code which will help me select locked/unlocked cells (as
required) in the selected range in one go. Something like 'Visible
cells only' and 'Blanks' options available in the 'Go to Special'
screen.

A macro that asks me "Go to:"
Locked Cells
Unlocked cells

Thanks a lot
Karthik Bhat

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Searching for locked/unlocked cells

Karthik,

Paste the sub below into your personal.xls and assign it to a custom toolbar button.

HTH,
Bernie
MS Excel MVP

Sub SelectedLockedUnlockedCells()
Dim myCell As Range
Dim myRange As Range
Dim SelLocked As Boolean
Dim myReply As Variant
myReply = MsgBox("Select Locked = ""Yes""" & Chr(10) & _
"Select UnLocked = ""No""", vbYesNoCancel)
If myReply = vbCancel Then Exit Sub

For Each myCell In Selection
If myReply = vbYes And myCell.Locked Then
If myRange Is Nothing Then
Set myRange = myCell
Else
Set myRange = Union(myRange, myCell)
End If
End If
If myReply = vbNo And Not myCell.Locked Then
If myRange Is Nothing Then
Set myRange = myCell
Else
Set myRange = Union(myRange, myCell)
End If
End If
Next myCell
If myRange Is Nothing Then
MsgBox "No " & IIf(myReply = vbYes, "Locked", "Unlocked") & _
" cells found in the current selection."
Exit Sub
End If
myRange.Select
End Sub



"Karthik Bhat - Bangalore" wrote in message
ups.com...
Hi All

I have a spreadsheet which has many cells locked, and they are spread
all across my worksheet.

I want a code which will help me select locked/unlocked cells (as
required) in the selected range in one go. Something like 'Visible
cells only' and 'Blanks' options available in the 'Go to Special'
screen.

A macro that asks me "Go to:"
Locked Cells
Unlocked cells

Thanks a lot
Karthik Bhat



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Searching for locked/unlocked cells

Karthik,
Depending on the WS Protection and .EnableSelection setting this may fail.

NickHK

"Bernie Deitrick" <deitbe @ consumer dot org wrote in message
...
Karthik,

Paste the sub below into your personal.xls and assign it to a custom

toolbar button.

HTH,
Bernie
MS Excel MVP

Sub SelectedLockedUnlockedCells()
Dim myCell As Range
Dim myRange As Range
Dim SelLocked As Boolean
Dim myReply As Variant
myReply = MsgBox("Select Locked = ""Yes""" & Chr(10) & _
"Select UnLocked = ""No""", vbYesNoCancel)
If myReply = vbCancel Then Exit Sub

For Each myCell In Selection
If myReply = vbYes And myCell.Locked Then
If myRange Is Nothing Then
Set myRange = myCell
Else
Set myRange = Union(myRange, myCell)
End If
End If
If myReply = vbNo And Not myCell.Locked Then
If myRange Is Nothing Then
Set myRange = myCell
Else
Set myRange = Union(myRange, myCell)
End If
End If
Next myCell
If myRange Is Nothing Then
MsgBox "No " & IIf(myReply = vbYes, "Locked", "Unlocked") & _
" cells found in the current selection."
Exit Sub
End If
myRange.Select
End Sub



"Karthik Bhat - Bangalore" wrote in message
ups.com...
Hi All

I have a spreadsheet which has many cells locked, and they are spread
all across my worksheet.

I want a code which will help me select locked/unlocked cells (as
required) in the selected range in one go. Something like 'Visible
cells only' and 'Blanks' options available in the 'Go to Special'
screen.

A macro that asks me "Go to:"
Locked Cells
Unlocked cells

Thanks a lot
Karthik Bhat





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
Viewing of protected locked or unlocked cells jmisenar Excel Worksheet Functions 2 April 22nd 09 04:58 AM
Display locked or Unlocked cells Jim May Excel Discussion (Misc queries) 2 August 30th 07 02:50 PM
Scope priviledges for locked/unlocked cells Jerry W. Lewis Excel Discussion (Misc queries) 2 July 30th 07 04:06 PM
paste locked cells and unlocked cells in protected sheet Angeline Excel Worksheet Functions 15 November 1st 06 11:51 PM
Highlighting locked or unlocked rows, Searching cells _[_2_] Excel Programming 1 November 5th 03 03:34 AM


All times are GMT +1. The time now is 11:18 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"