• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Select only unlocked cells

Ronald

Member
Hi,

Is there a way (in vba) to select only unlocked cells from a tab (not marked as locked in cell properties)?

This in Excel 2010.

Thanks in advance.

Ronald.
 
This seems to work
Code:
Sub SelectUnlockedCells()
    Dim WorkRange As Range
    Dim FoundCells As Range
    Dim Cell As Range
    Set WorkRange = ActiveSheet.UsedRange
    For Each Cell In WorkRange
        If Cell.Locked = False Then
            If FoundCells Is Nothing Then
                Set FoundCells = Cell
            Else
                Set FoundCells = Union(FoundCells, Cell)
            End If
        End If
    Next Cell
    If FoundCells Is Nothing Then
        MsgBox "All cells are locked."

    Else
        FoundCells.Select
    End If
End Sub

Copied from:
http://spreadsheetpage.com/index.php/tip/selecting_all_unlocked_cells/
 
Back
Top