Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Select all the unlocked cells on a worksheet

Hi,

does anyone know how to select all the unlocked cells on a
worksheet.

All i need to do is show which cells are unlocked without
changing the formatting of the cells.

Thanks for any help,

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Select all the unlocked cells on a worksheet

You can use the following code

Dim rgeStart As Range
Dim rgeEnd As Range
Dim Z As Integer, Y As Integer
Dim str1 As String, str2 As String

Set rgeStart = Application.Range("A1")
Set rgeEnd = Application.Cells.SpecialCells
(xlCellTypeLastCell)

For Z = 1 To rgeEnd.Row
For Y = 1 To rgeEnd.Column
If Not Application.Cells(Z, Y).Locked Then
str1 = Mid(Application.Cells(Z, Y).Address, 2, 1)
& Mid(Application.Cells(Z, Y).Address, 4, 1) & ","
str2 = str2 & str1
End If
Next Y
Next Z
str2 = Left$(str2, Len(str2) - 1)
Application.Range(str2).Select


-----Original Message-----
Hi,

does anyone know how to select all the unlocked cells on

a
worksheet.

All i need to do is show which cells are unlocked without
changing the formatting of the cells.

Thanks for any help,

Steven
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Select all the unlocked cells on a worksheet

The obvious is to loop through all the cells in the sheet and check the
locked property of the cell, building a union.

If the sheet is protected, you can use sendkeys to travel through them:

Sub GetUnlocked()
Dim rng As Range
Dim cell As Range
SendKeys "{tab}", True
Set rng = ActiveCell
Debug.Print rng.Address
SendKeys "{tab}", True
Set cell = ActiveCell
Debug.Print cell.Address
Do While Intersect(cell, rng) Is Nothing
Set rng = Union(rng, cell)
SendKeys "{tab}", True
Set cell = ActiveCell
Debug.Print rng.Address, cell.Address
Loop
rng.Select

End Sub

--
Regards,
Tom Ogilvy

Steven Revell wrote in message
...
Hi,

does anyone know how to select all the unlocked cells on a
worksheet.

All i need to do is show which cells are unlocked without
changing the formatting of the cells.

Thanks for any help,

Steven



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
Locked Several Worksheets, allow format cells/select unlocked cell Ana24 Excel Discussion (Misc queries) 2 September 26th 09 01:15 AM
Moving from unlocked cells to unlocked cells in an excel form Stacey Lee Excel Worksheet Functions 1 April 24th 06 08:44 PM
Marking unlocked cells in active worksheet Zadig Galbaras Excel Discussion (Misc queries) 4 August 13th 05 08:05 PM
how do you "select locked cells" w/o "select unlocked cells"? princejohnpaulfin Excel Discussion (Misc queries) 3 July 16th 05 03:53 AM
How can I merge unlocked cells in a worksheet that has been protec NeedMergeHelp Excel Discussion (Misc queries) 2 December 7th 04 01:20 AM


All times are GMT +1. The time now is 02:19 AM.

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"