Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Colour cell when number changes

If the number in a cell is changed and it is larger than the original number
I want the cell to be highlighted in a green colour. If the number is lower
than the original I want the cell to be highlighted in red.
Any suggestions gratefully accepted.
Roger
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Colour cell when number changes

Hi Jolly:

Put the following in worksheet code:

Dim v
Private Sub Worksheet_Activate()
v = Cells(1, 1).Value
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then
Exit Sub
End If
If Cells(1, 1).Value v Then
Cells(1, 1).Interior.ColorIndex = 50
End If
If Cells(1, 1).Value < v Then
Cells(1, 1).Interior.ColorIndex = 3
End If
End Sub


When the sheet is activated, the first macro just records the value in A1 in
a static variable v. If A1 changes, the second macro compares the new value
to v and colours the cell in an appropriate fashion.
--
Gary's Student


"Jolly Roger" wrote:

If the number in a cell is changed and it is larger than the original number
I want the cell to be highlighted in a green colour. If the number is lower
than the original I want the cell to be highlighted in red.
Any suggestions gratefully accepted.
Roger

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Colour cell when number changes


--
Gary''s Student


"Jolly Roger" wrote:

If the number in a cell is changed and it is larger than the original number
I want the cell to be highlighted in a green colour. If the number is lower
than the original I want the cell to be highlighted in red.
Any suggestions gratefully accepted.
Roger

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default Colour cell when number changes


Holy Macro!

Would this get put into visual basic editor?

Gary''s Student wrote:
Hi Jolly:

Put the following in worksheet code:

Dim v
Private Sub Worksheet_Activate()
v = Cells(1, 1).Value
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then
Exit Sub
End If
If Cells(1, 1).Value v Then
Cells(1, 1).Interior.ColorIndex = 50
End If
If Cells(1, 1).Value < v Then
Cells(1, 1).Interior.ColorIndex = 3
End If
End Sub


When the sheet is activated, the first macro just records the value in A1 in
a static variable v. If A1 changes, the second macro compares the new value
to v and colours the cell in an appropriate fashion.
--
Gary's Student


"Jolly Roger" wrote:

If the number in a cell is changed and it is larger than the original number
I want the cell to be highlighted in a green colour. If the number is lower
than the original I want the cell to be highlighted in red.
Any suggestions gratefully accepted.
Roger


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Colour cell when number changes

Right-click on your worksheet tab and "View Code".

Copy/paste into the sheet module that appears.

Alt + q to close.


Gord Dibben MS Excel MVP

On 7 Oct 2006 14:17:38 -0700, "steveK" wrote:


Holy Macro!

Would this get put into visual basic editor?

Gary''s Student wrote:
Hi Jolly:

Put the following in worksheet code:

Dim v
Private Sub Worksheet_Activate()
v = Cells(1, 1).Value
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then
Exit Sub
End If
If Cells(1, 1).Value v Then
Cells(1, 1).Interior.ColorIndex = 50
End If
If Cells(1, 1).Value < v Then
Cells(1, 1).Interior.ColorIndex = 3
End If
End Sub


When the sheet is activated, the first macro just records the value in A1 in
a static variable v. If A1 changes, the second macro compares the new value
to v and colours the cell in an appropriate fashion.
--
Gary's Student


"Jolly Roger" wrote:

If the number in a cell is changed and it is larger than the original number
I want the cell to be highlighted in a green colour. If the number is lower
than the original I want the cell to be highlighted in red.
Any suggestions gratefully accepted.
Roger




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Colour cell when number changes

Hi,
I pasted this into the sheet. It works for cell A1. How do I use it on the
whole sheet?
  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Colour cell when number changes

Use the formatting paintbrush to copy the formatting to cells you want with that
CF


Gord Dibben MS Excel MVP

On Sun, 8 Oct 2006 03:20:02 -0700, Jolly Roger
wrote:

Hi,
I pasted this into the sheet. It works for cell A1. How do I use it on the
whole sheet?


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
Change cell Colour when a number of days have been passed SR7133 Excel Discussion (Misc queries) 4 March 1st 06 10:49 PM
Urgent date/scheduling calc needed jct Excel Worksheet Functions 3 February 24th 06 01:36 AM
Return SEARCHED Column Number of Numeric Label and Value Sam via OfficeKB.com Excel Worksheet Functions 23 January 30th 06 06:16 PM
Instead of a negative number, I'd like to show zero... Dr. Darrell Excel Worksheet Functions 6 December 7th 05 08:21 PM
Fill colour a cell from the linked cell Stephen C Excel Discussion (Misc queries) 1 September 28th 05 03:56 PM


All times are GMT +1. The time now is 09:56 AM.

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"