Select entire column in a dynamic named range, except the last row

Jakejake

New Member
Joined
Jun 16, 2021
Messages
8
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
Good morning all.

I'm trying to select a column (9th one) in my dynamic named range, and remove the cell protection from it.

I can do this via:

.columns(9).Locked = False

However, I wish to keep the very last row locked, but being dynamic I cannot specify an exact row. It moves up and down...

Is there a way I can do this, perhaps via Count or Offset?

Please help.

Thanks in advance
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
This should give you a head start on adjusting your code.

VBA Code:
Sub UnlockColumn()
    Dim r1 As Range
    Dim r2 As Range
   
    Set r1 = Range("rng")
   
    Set r2 = r1.Columns(9)
   
    Set r2 = r2.Resize(r2.Rows.Count - 1)

    r2.Columns(1).Locked = False
  
End Sub
 
Upvote 0
.Columns(9).Resize(.Rows.Count-1).Locked = False
Perfect, thank you.

Out of curiosity the resize command seems to resize the range I guess. So I could always adjust it to something like "third row up from the bottom" etc...? '-1' becomes '-3' I guess.
 
Upvote 0

Forum statistics

Threads
1,214,837
Messages
6,121,883
Members
449,057
Latest member
Moo4247

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top