Home > Enterprise >  Set table's body range and all cells below it as unlocked
Set table's body range and all cells below it as unlocked

Time:09-01

I want to set the union of the table's body range and all of the cells below the table to unlocked. How can I do this? More specifically I don't know how to target the area below the table...

CodePudding user response:

You could do this:

With ActiveSheet.ListObjects(1).DataBodyRange.Rows(1)
    .Resize(1   Rows.Count - .Row).Locked = False
End With

CodePudding user response:

Referencing Ranges

Sub ReferencingRanges()
    
    Dim srg As Range: Set srg = ThisWorkbook.Worksheets("Sheet1") _
        .ListObjects("Table1").DataBodyRange
    
    Dim drg As Range
    
    With srg
        
        ' Reference the range.
        Set drg = .Cells
        Debug.Print "DataBodyRange: " & drg.Address(0, 0)
        
        ' Reference the range below the range.
        Set drg = .Resize(.Worksheet.Rows.Count - .Row - .Rows.Count   1) _
            .Offset(.Rows.Count)
        Debug.Print "Below... :     " & drg.Address(0, 0)
        
        ' Reference the range and the range below the range.
        Set drg = .Resize(.Worksheet.Rows.Count - .Row   1)
        Debug.Print "Both... :      " & drg.Address(0, 0)
    
    End With
    
    'drg.Locked = False
    
End Sub
  • Related