Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change cell Colour when a number of days have been passed | Excel Discussion (Misc queries) | |||
Urgent date/scheduling calc needed | Excel Worksheet Functions | |||
Return SEARCHED Column Number of Numeric Label and Value | Excel Worksheet Functions | |||
Instead of a negative number, I'd like to show zero... | Excel Worksheet Functions | |||
Fill colour a cell from the linked cell | Excel Discussion (Misc queries) |