Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Unable to set the Locked property of the range class

Here's the code:

Option Explicit
Private Sub Workbook_Open()

Dim i As Integer, C As Range
With Workbooks("MasterOrder.xls").Worksheets("Master Order")
.Unprotect Password:="SGB"
.Cells.Locked = False
i = .Range("I10").Value
.Range("I10").Value = i + 1
For Each C In .Range("A1:N61")
With C
If Not C.Interior.ColorIndex = 34 Then
C.Locked = True
End If
End With
Next
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells
End With
End Sub

Q1: why that error message please?
Q2: can I improve the code please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Unable to set the Locked property of the range class

Try this Stuart

For Each C In .Range("A1:N61")
If C.Interior.ColorIndex < 34 Then
C.Locked = True
End If
Next


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message ...
Here's the code:

Option Explicit
Private Sub Workbook_Open()

Dim i As Integer, C As Range
With Workbooks("MasterOrder.xls").Worksheets("Master Order")
.Unprotect Password:="SGB"
.Cells.Locked = False
i = .Range("I10").Value
.Range("I10").Value = i + 1
For Each C In .Range("A1:N61")
With C
If Not C.Interior.ColorIndex = 34 Then
C.Locked = True
End If
End With
Next
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells
End With
End Sub

Q1: why that error message please?
Q2: can I improve the code please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Unable to set the Locked property of the range class

Ron,

Manythanks ....but same error message.

BTW this is Excel 2000 under Win 2K.

Regards and thanks.

"Ron de Bruin" wrote in message
...
Try this Stuart

For Each C In .Range("A1:N61")
If C.Interior.ColorIndex < 34 Then
C.Locked = True
End If
Next


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message

...
Here's the code:

Option Explicit
Private Sub Workbook_Open()

Dim i As Integer, C As Range
With Workbooks("MasterOrder.xls").Worksheets("Master Order")
.Unprotect Password:="SGB"
.Cells.Locked = False
i = .Range("I10").Value
.Range("I10").Value = i + 1
For Each C In .Range("A1:N61")
With C
If Not C.Interior.ColorIndex = 34 Then
C.Locked = True
End If
End With
Next
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells
End With
End Sub

Q1: why that error message please?
Q2: can I improve the code please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Unable to set the Locked property of the range class

It seems to run, but then fail on the same cell each time,
namely "K12". This cell is merged with "L12".

Could merged cells be the problem?

Regards.

"Ron de Bruin" wrote in message
...
Try this Stuart

For Each C In .Range("A1:N61")
If C.Interior.ColorIndex < 34 Then
C.Locked = True
End If
Next


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message

...
Here's the code:

Option Explicit
Private Sub Workbook_Open()

Dim i As Integer, C As Range
With Workbooks("MasterOrder.xls").Worksheets("Master Order")
.Unprotect Password:="SGB"
.Cells.Locked = False
i = .Range("I10").Value
.Range("I10").Value = i + 1
For Each C In .Range("A1:N61")
With C
If Not C.Interior.ColorIndex = 34 Then
C.Locked = True
End If
End With
Next
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells
End With
End Sub

Q1: why that error message please?
Q2: can I improve the code please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Unable to set the Locked property of the range class

Stuart

Yes this is your problem

Don't Merge cells, Always trouble

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message ...
It seems to run, but then fail on the same cell each time,
namely "K12". This cell is merged with "L12".

Could merged cells be the problem?

Regards.

"Ron de Bruin" wrote in message
...
Try this Stuart

For Each C In .Range("A1:N61")
If C.Interior.ColorIndex < 34 Then
C.Locked = True
End If
Next


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message

...
Here's the code:

Option Explicit
Private Sub Workbook_Open()

Dim i As Integer, C As Range
With Workbooks("MasterOrder.xls").Worksheets("Master Order")
.Unprotect Password:="SGB"
.Cells.Locked = False
i = .Range("I10").Value
.Range("I10").Value = i + 1
For Each C In .Range("A1:N61")
With C
If Not C.Interior.ColorIndex = 34 Then
C.Locked = True
End If
End With
Next
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells
End With
End Sub

Q1: why that error message please?
Q2: can I improve the code please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Unable to set the Locked property of the range class

Many thanks, and for the advice.
Regards.

"Ron de Bruin" wrote in message
...
Stuart

Yes this is your problem

Don't Merge cells, Always trouble

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message

...
It seems to run, but then fail on the same cell each time,
namely "K12". This cell is merged with "L12".

Could merged cells be the problem?

Regards.

"Ron de Bruin" wrote in message
...
Try this Stuart

For Each C In .Range("A1:N61")
If C.Interior.ColorIndex < 34 Then
C.Locked = True
End If
Next


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Stuart" wrote in message

...
Here's the code:

Option Explicit
Private Sub Workbook_Open()

Dim i As Integer, C As Range
With Workbooks("MasterOrder.xls").Worksheets("Master Order")
.Unprotect Password:="SGB"
.Cells.Locked = False
i = .Range("I10").Value
.Range("I10").Value = i + 1
For Each C In .Range("A1:N61")
With C
If Not C.Interior.ColorIndex = 34 Then
C.Locked = True
End If
End With
Next
.Protect Password:="SGB"
.EnableSelection = xlUnlockedCells
End With
End Sub

Q1: why that error message please?
Q2: can I improve the code please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.708 / Virus Database: 464 - Release Date: 18/06/2004






---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.710 / Virus Database: 466 - Release Date: 23/06/2004


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
Unable to set the FormulaArrary property of the range class RTK Excel Worksheet Functions 0 April 13th 10 08:38 AM
unable to set the formula array property of the range class JLP Excel Worksheet Functions 3 November 18th 08 10:54 PM
Unable to set the Values property of the Series class rafael garcia Charts and Charting in Excel 1 September 25th 06 04:31 PM
Runtime 1004 unable to get find property of range class Eric Excel Programming 2 January 30th 04 01:06 PM
Unable to set the Locked Property of the Range Class Stuart[_5_] Excel Programming 0 July 15th 03 06:59 PM


All times are GMT +1. The time now is 09:15 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"