Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Formatting the background of unlocked cells

Hello,

I have this code that enables users to change the font colour of
unlocked cells to red of a protected sheet without needing the
password:

Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="password"
With Selection.Font
.Color = -16776961
End With
End With
ActiveSheet.Protect Password:="password"
End Sub

How can I use this same code but format the background colour of a
cell to red rather then the font colour?

Thanks for all of your help!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Formatting the background of unlocked cells

You want to use .Interior.ColorIndex = 3

put this in and run to see all the colors if you want.

Sub main()
For i = 1 To 50
Cells(i, 1).Interior.ColorIndex = i
Next
End Sub
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:

Hello,

I have this code that enables users to change the font colour of
unlocked cells to red of a protected sheet without needing the
password:

Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="password"
With Selection.Font
.Color = -16776961
End With
End With
ActiveSheet.Protect Password:="password"
End Sub

How can I use this same code but format the background colour of a
cell to red rather then the font colour?

Thanks for all of your help!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Formatting the background of unlocked cells

On Nov 20, 11:20 am, John Bundy (remove) wrote:
You want to use .Interior.ColorIndex = 3

put this in and run to see all the colors if you want.

Sub main()
For i = 1 To 50
Cells(i, 1).Interior.ColorIndex = i
Next
End Sub
--
-John
Please rate when your question is answered to help us and others know what
is helpful.



" wrote:
Hello,


I have this code that enables users to change the font colour of
unlocked cells to red of a protected sheet without needing the
password:


Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="password"
With Selection.Font
.Color = -16776961
End With
End With
ActiveSheet.Protect Password:="password"
End Sub


How can I use this same code but format the background colour of a
cell to red rather then the font colour?


Thanks for all of your help!- Hide quoted text -


- Show quoted text -


Hi John,

Thanks so much for your help,

I have integrated this into the code as follows but I recieve an error
when I do.
I am not sure what I am doing wrong?

Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="overview"
With Selection.Font
.Interior.ColorIndex = 3
End With
End With
ActiveSheet.Protect Password:="overview"
End Sub

Thanks again!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Formatting the background of unlocked cells

You should omit the Font reference like:

Selection.Interior.ColorIndex = 3

" wrote:

On Nov 20, 11:20 am, John Bundy (remove) wrote:
You want to use .Interior.ColorIndex = 3

put this in and run to see all the colors if you want.

Sub main()
For i = 1 To 50
Cells(i, 1).Interior.ColorIndex = i
Next
End Sub
--
-John
Please rate when your question is answered to help us and others know what
is helpful.



" wrote:
Hello,


I have this code that enables users to change the font colour of
unlocked cells to red of a protected sheet without needing the
password:


Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="password"
With Selection.Font
.Color = -16776961
End With
End With
ActiveSheet.Protect Password:="password"
End Sub


How can I use this same code but format the background colour of a
cell to red rather then the font colour?


Thanks for all of your help!- Hide quoted text -


- Show quoted text -


Hi John,

Thanks so much for your help,

I have integrated this into the code as follows but I recieve an error
when I do.
I am not sure what I am doing wrong?

Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="overview"
With Selection.Font
.Interior.ColorIndex = 3
End With
End With
ActiveSheet.Protect Password:="overview"
End Sub

Thanks again!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Formatting the background of unlocked cells

P.S. Font is for characters and Interior is for background.

" wrote:

On Nov 20, 11:20 am, John Bundy (remove) wrote:
You want to use .Interior.ColorIndex = 3

put this in and run to see all the colors if you want.

Sub main()
For i = 1 To 50
Cells(i, 1).Interior.ColorIndex = i
Next
End Sub
--
-John
Please rate when your question is answered to help us and others know what
is helpful.



" wrote:
Hello,


I have this code that enables users to change the font colour of
unlocked cells to red of a protected sheet without needing the
password:


Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="password"
With Selection.Font
.Color = -16776961
End With
End With
ActiveSheet.Protect Password:="password"
End Sub


How can I use this same code but format the background colour of a
cell to red rather then the font colour?


Thanks for all of your help!- Hide quoted text -


- Show quoted text -


Hi John,

Thanks so much for your help,

I have integrated this into the code as follows but I recieve an error
when I do.
I am not sure what I am doing wrong?

Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="overview"
With Selection.Font
.Interior.ColorIndex = 3
End With
End With
ActiveSheet.Protect Password:="overview"
End Sub

Thanks again!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Formatting the background of unlocked cells

On Nov 20, 1:54 pm, JLGWhiz wrote:
P.S. Font is for characters and Interior is for background.



" wrote:
On Nov 20, 11:20 am, John Bundy (remove) wrote:
You want to use .Interior.ColorIndex = 3


put this in and run to see all the colors if you want.


Sub main()
For i = 1 To 50
Cells(i, 1).Interior.ColorIndex = i
Next
End Sub
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


" wrote:
Hello,


I have this code that enables users to change the font colour of
unlocked cells to red of a protected sheet without needing the
password:


Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="password"
With Selection.Font
.Color = -16776961
End With
End With
ActiveSheet.Protect Password:="password"
End Sub


How can I use this same code but format the background colour of a
cell to red rather then the font colour?


Thanks for all of your help!- Hide quoted text -


- Show quoted text -


Hi John,


Thanks so much for your help,


I have integrated this into the code as follows but I recieve an error
when I do.
I am not sure what I am doing wrong?


Sub Macro2()
With Selection
ActiveSheet.Unprotect Password:="overview"
With Selection.Font
.Interior.ColorIndex = 3
End With
End With
ActiveSheet.Protect Password:="overview"
End Sub


Thanks again!- Hide quoted text -


- Show quoted text -


That worked!
Thanks!
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
Formatting unlocked cells and stop users from pasting [email protected] Excel Programming 4 October 26th 07 01:55 PM
How can I have formatting options like merge cells ,Bold,active for the unlocked cells of the protected worksheet.Is it possible in excel? divya Excel Programming 2 July 20th 06 02:04 PM
How can I have formatting toolbar active for the unprotected(unlocked) cells of the protected worksheet??? sanam Excel Discussion (Misc queries) 6 July 20th 06 01:42 PM
Moving from unlocked cells to unlocked cells in an excel form Stacey Lee Excel Worksheet Functions 1 April 24th 06 08:44 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 12:39 PM.

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"