Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Assign and clear value to unlocked cells in a protected sheet

I want to create two buttons, one that will give the unlocked cells in a
range H12:H400 the text "Gray" and the other will clear the contents. Any
help will be appriciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 595
Default Assign and clear value to unlocked cells in a protected sheet

On Fri, 1 Aug 2008 08:55:00 -0700, Ram B
wrote:

I want to create two buttons, one that will give the unlocked cells in a
range H12:H400 the text "Gray" and the other will clear the contents. Any
help will be appriciated.


Sub MarkGrey()

Dim rCell As Range

For Each rCell In Sheet1.UsedRange
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub

Make a new sub and change the line to clearcontents for the button to clear.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Assign and clear value to unlocked cells in a protected sheet

Thanks - Although this works on the entire sheet, How can get this to a
specific range say range I12:I384, I would like to leave the rest of the
sheet untouched. What I am trying to do is assign specific text to a specific
cllumn by creating a button on the top of the column. I tried this but it
doesnot work

Sub MarkGrey()
Range("I12:I384").Select
Dim rCell As Range

For Each rCell In Worksheets("Passive Safety").UsedRange
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub
"Dick Kusleika" wrote:

On Fri, 1 Aug 2008 08:55:00 -0700, Ram B
wrote:

I want to create two buttons, one that will give the unlocked cells in a
range H12:H400 the text "Gray" and the other will clear the contents. Any
help will be appriciated.


Sub MarkGrey()

Dim rCell As Range

For Each rCell In Sheet1.UsedRange
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub

Make a new sub and change the line to clearcontents for the button to clear.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Assign and clear value to unlocked cells in a protected sheet

Sub MarkGrey()

Dim rCell As Range
Dim rng As Range
Set rng = Worksheets("Passive Safety").Range("I12:I384")
For Each rCell In rng
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub


Gord Dibben MS Excel MVP

On Sat, 2 Aug 2008 06:45:05 -0700, Ram B
wrote:

Thanks - Although this works on the entire sheet, How can get this to a
specific range say range I12:I384, I would like to leave the rest of the
sheet untouched. What I am trying to do is assign specific text to a specific
cllumn by creating a button on the top of the column. I tried this but it
doesnot work

Sub MarkGrey()
Range("I12:I384").Select
Dim rCell As Range

For Each rCell In Worksheets("Passive Safety").UsedRange
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub
"Dick Kusleika" wrote:

On Fri, 1 Aug 2008 08:55:00 -0700, Ram B
wrote:

I want to create two buttons, one that will give the unlocked cells in a
range H12:H400 the text "Gray" and the other will clear the contents. Any
help will be appriciated.


Sub MarkGrey()

Dim rCell As Range

For Each rCell In Sheet1.UsedRange
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell

End Sub

Make a new sub and change the line to clearcontents for the button to clear.
--
Dick Kusleika
Microsoft MVP-Excel
http://www.dailydoseofexcel.com


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Assign and clear value to unlocked cells in a protected sheet

Thanks guys, It works BUT


It goes at 2 cells a second or in other words it take approx 3 minutes to go
300+ cells. Ansy suggestions as to how I can speed it up?


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Assign and clear value to unlocked cells in a protected sheet

Any chance you have worksheet_change events that fire with each change?

If yes, you could tell excel to stop looking for those changes while your code
does the work.

Sub MarkGrey()

Dim rCell As Range
Dim rng As Range

Set rng = Worksheets("Passive Safety").Range("I12:I384")

application.enableevents = false
For Each rCell In rng
If Not rCell.Locked Then
rCell.Value = "Gray"
'rcell.ClearContents
End If
Next rCell
application.enableevents = true

End Sub

Ram B wrote:

Thanks guys, It works BUT

It goes at 2 cells a second or in other words it take approx 3 minutes to go
300+ cells. Ansy suggestions as to how I can speed it up?


--

Dave Peterson
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
Unlocked Cells in Protected Sheet KMA Excel Worksheet Functions 3 November 8th 07 07:08 PM
Allowing comments in unlocked cells within protected sheet Suz Excel Discussion (Misc queries) 1 February 6th 07 07:35 PM
allow comments, unlocked cells, protected sheet Jeff Higgins Excel Programming 3 October 7th 05 02:43 PM
move between unlocked cells on protected sheet ayanna Excel Discussion (Misc queries) 1 April 27th 05 05:59 PM
Formatting unlocked cells on protected sheet Lee Schipper Excel Programming 1 April 13th 05 08:00 PM


All times are GMT +1. The time now is 06:02 PM.

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"