Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Code bombs at line indicated, why?

Sub TestForProtect()
Dim myrng As Range
Dim c As Range
Set myrng = Range("A1:B5")
For Each c In myrng
If c.Locked = False Then
c.Interior.ColorIndex = 6 <<< R/T 1004 ***
End If
Next c
End Sub

*** Unable to set the Colorindex property of the Iterior Class... ????

How can I fix?
TIA,


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Code bombs at line indicated, why?

One possibility is, that you have your sheet protected.
If so, unprotect it in the beginning and protect it at the end of the macro.

Wolf

"Jim May" wrote:

Sub TestForProtect()
Dim myrng As Range
Dim c As Range
Set myrng = Range("A1:B5")
For Each c In myrng
If c.Locked = False Then
c.Interior.ColorIndex = 6 <<< R/T 1004 ***
End If
Next c
End Sub

*** Unable to set the Colorindex property of the Iterior Class... ????

How can I fix?
TIA,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code bombs at line indicated, why?

If the sheet is protected, then even an unlocked cell can not normally be
formatted. (in xl2002 and later, there are options for this). In general,
things that you can't do manually can not be done in code either. You also
might look at the UserInterFaceOnly setting of the protect method for
greater flexibility.

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:pldWe.23744$8q.15872@lakeread01...
Sub TestForProtect()
Dim myrng As Range
Dim c As Range
Set myrng = Range("A1:B5")
For Each c In myrng
If c.Locked = False Then
c.Interior.ColorIndex = 6 <<< R/T 1004 ***
End If
Next c
End Sub

*** Unable to set the Colorindex property of the Iterior Class... ????

How can I fix?
TIA,




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Code bombs at line indicated, why?

Thanks Tom,

"Tom Ogilvy" wrote in message
...
If the sheet is protected, then even an unlocked cell can not normally be
formatted. (in xl2002 and later, there are options for this). In
general,
things that you can't do manually can not be done in code either. You
also
might look at the UserInterFaceOnly setting of the protect method for
greater flexibility.

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:pldWe.23744$8q.15872@lakeread01...
Sub TestForProtect()
Dim myrng As Range
Dim c As Range
Set myrng = Range("A1:B5")
For Each c In myrng
If c.Locked = False Then
c.Interior.ColorIndex = 6 <<< R/T 1004 ***
End If
Next c
End Sub

*** Unable to set the Colorindex property of the Iterior Class... ????

How can I fix?
TIA,






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
Macro code to put series name next to individual line in line grap Otani Charts and Charting in Excel 3 February 23rd 10 07:24 PM
Code to delete a Line in a another code helmekki[_88_] Excel Programming 1 August 8th 05 01:14 AM
sumproduct bombs out JN Excel Worksheet Functions 15 July 11th 05 11:50 PM
Continue line of VBA code on the next line peacelittleone Excel Programming 9 June 24th 05 07:46 PM
Macro runs in Excel 2003, bombs in XP - Compatability question Harry[_8_] Excel Programming 3 March 3rd 05 08:40 AM


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