Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default locking cells from specific point to infinity

I would like to lock all cells starting from J1 to infinity and from A62 to
infinity using VB.

Anyone have any ideas?

Ken


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default locking cells from specific point to infinity

By default, all cells are locked, so you first need to unlock
everything and then selectively lock the desired ranges. E.g.,

Sub AAA()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
With WS
.Cells.Locked = False
.Cells(1, "J").Resize(.Rows.Count, 1).Locked = True
.Cells(62, "A").Resize(.Rows.Count - 61).Locked = True
.Protect
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 12 Sep 2009 11:58:49 -0700, "Ken"
wrote:

I would like to lock all cells starting from J1 to infinity and from A62 to
infinity using VB.

Anyone have any ideas?

Ken

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default locking cells from specific point to infinity

Thanks for your reply!

While attempting to figure out your code, I'm curious as to why:
1) are you using Resize
2) is the Rows.Count -61, rather then Rows.Count, 62

Ken

"Chip Pearson" wrote in message
...
By default, all cells are locked, so you first need to unlock
everything and then selectively lock the desired ranges. E.g.,

Sub AAA()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
With WS
.Cells.Locked = False
.Cells(1, "J").Resize(.Rows.Count, 1).Locked = True
.Cells(62, "A").Resize(.Rows.Count - 61).Locked = True
.Protect
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 12 Sep 2009 11:58:49 -0700, "Ken"
wrote:

I would like to lock all cells starting from J1 to infinity and from A62
to
infinity using VB.

Anyone have any ideas?

Ken



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default locking cells from specific point to infinity

Run the macro below with a active blank sheet and you will see in the
message box that with - 61 it selects from A62 through the last row of the
sheet, but with - 62, the last row is not part of the selection.


"Ken" wrote in message
...
Thanks for your reply!

While attempting to figure out your code, I'm curious as to why:
1) are you using Resize
2) is the Rows.Count -61, rather then Rows.Count, 62

Ken

"Chip Pearson" wrote in message
...
By default, all cells are locked, so you first need to unlock
everything and then selectively lock the desired ranges. E.g.,

Sub AAA()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
With WS
.Cells.Locked = False
.Cells(1, "J").Resize(.Rows.Count, 1).Locked = True
.Cells(62, "A").Resize(.Rows.Count - 61).Locked = True
.Protect
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 12 Sep 2009 11:58:49 -0700, "Ken"
wrote:

I would like to lock all cells starting from J1 to infinity and from A62
to
infinity using VB.

Anyone have any ideas?

Ken





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default locking cells from specific point to infinity

Sorry, I see that I should have explained this better.

I only want the user to have access to A1 through I60
So, what I would like is to lock all rows and columns down and to the right
of J1.
Also all rows and columns down and to the right of A61

Once again, my appologies for not being more specific in the first place.

Ken

"JLGWhiz" wrote in message
...
Run the macro below with a active blank sheet and you will see in the
message box that with - 61 it selects from A62 through the last row of the
sheet, but with - 62, the last row is not part of the selection.


"Ken" wrote in message
...
Thanks for your reply!

While attempting to figure out your code, I'm curious as to why:
1) are you using Resize
2) is the Rows.Count -61, rather then Rows.Count, 62

Ken

"Chip Pearson" wrote in message
...
By default, all cells are locked, so you first need to unlock
everything and then selectively lock the desired ranges. E.g.,

Sub AAA()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
With WS
.Cells.Locked = False
.Cells(1, "J").Resize(.Rows.Count, 1).Locked = True
.Cells(62, "A").Resize(.Rows.Count - 61).Locked = True
.Protect
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 12 Sep 2009 11:58:49 -0700, "Ken"
wrote:

I would like to lock all cells starting from J1 to infinity and from A62
to
infinity using VB.

Anyone have any ideas?

Ken









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default locking cells from specific point to infinity

Sub lockit()
Cells.Locked = True
Range("A1:I61").Locked = False
End Sub

Don't forget...........the worksheet must be protected after the above runs.


Gord Dibben MS Excel MVP

On Sat, 12 Sep 2009 14:38:51 -0700, "Ken" wrote:

Sorry, I see that I should have explained this better.

I only want the user to have access to A1 through I60
So, what I would like is to lock all rows and columns down and to the right
of J1.
Also all rows and columns down and to the right of A61

Once again, my appologies for not being more specific in the first place.

Ken

"JLGWhiz" wrote in message
...
Run the macro below with a active blank sheet and you will see in the
message box that with - 61 it selects from A62 through the last row of the
sheet, but with - 62, the last row is not part of the selection.


"Ken" wrote in message
...
Thanks for your reply!

While attempting to figure out your code, I'm curious as to why:
1) are you using Resize
2) is the Rows.Count -61, rather then Rows.Count, 62

Ken

"Chip Pearson" wrote in message
...
By default, all cells are locked, so you first need to unlock
everything and then selectively lock the desired ranges. E.g.,

Sub AAA()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
With WS
.Cells.Locked = False
.Cells(1, "J").Resize(.Rows.Count, 1).Locked = True
.Cells(62, "A").Resize(.Rows.Count - 61).Locked = True
.Protect
End With
End Sub

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Sat, 12 Sep 2009 11:58:49 -0700, "Ken"
wrote:

I would like to lock all cells starting from J1 to infinity and from A62
to
infinity using VB.

Anyone have any ideas?

Ken







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
how to plot an infinity point in Excel Ghada Excel Discussion (Misc queries) 2 April 4th 23 10:11 AM
trouble locking specific cells [email protected] Excel Worksheet Functions 2 June 19th 07 05:14 PM
Locking specific cells in a workbook Sarah Excel Discussion (Misc queries) 2 April 17th 07 03:16 AM
locking formula in cells in without locking whole sheet SuziQ Excel Discussion (Misc queries) 1 July 21st 06 03:58 PM
Locking Specific Cells [email protected][_2_] Excel Programming 3 March 1st 06 04:16 PM


All times are GMT +1. The time now is 11:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"