Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Changing Cell Properties when sheet is protected

Would like to change a cells backgound color based on the value of the cell
using Vba.
If the value in cell is 0 then turn it green.
If value in cell is < 0 then turn it red.
Would like to have the sheet protected to guard against user changes to cell
formulas.
Using EXCEL 2003.
Any help much appreciated.

--
Cam
  #2   Report Post  
Posted to microsoft.public.excel.programming
JMB JMB is offline
external usenet poster
 
Posts: 2,062
Default Changing Cell Properties when sheet is protected

Conditional formatting is tailor made for this operation, but if you must use
VBA...

Any particular cell(s) or just any cell on the worksheet? Do you want to
color the cells as the data is entered or is the data already entered and you
want to color the cells after the fact?

If you right click on the sheet tab, select view code, and paste this into
the code window, it should shade any cell on the sheet as data is entered
into it (assuming you're using the default color palette):

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo CleanUp
Application.EnableEvents = False

With Target
If IsNumeric(.Value) Then
If .Value < 0 Then
.Interior.ColorIndex = 3
ElseIf .Value 0 Then
.Interior.ColorIndex = 10
End If
End If
End With

CleanUp:
Application.EnableEvents = True
End Sub


"Simmer2" wrote:

Would like to change a cells backgound color based on the value of the cell
using Vba.
If the value in cell is 0 then turn it green.
If value in cell is < 0 then turn it red.
Would like to have the sheet protected to guard against user changes to cell
formulas.
Using EXCEL 2003.
Any help much appreciated.

--
Cam

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
Changing Font in an unlocked cell in a protected sheet. Mark T UK Excel Discussion (Misc queries) 2 October 3rd 08 12:03 PM
Can't Paste after Changing Cell Properties [email protected] Excel Programming 0 August 1st 07 09:48 AM
Changing Cell Properties Interfering with Clipboard [email protected] Excel Programming 0 July 27th 07 09:40 AM
Cell changing it's properties jtpeters New Users to Excel 0 December 27th 05 10:09 PM
Changing a Chart on a Protected Sheet Peter M[_3_] Excel Programming 2 February 24th 04 06:48 PM


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