» Set background color depending on value verification using VBA in Microsoft Excel
CATEGORY - General Topics in VBA
VERSION - All Microsoft Excel Versions
For entries or changes of formula values, a proof with the prior values is to be initiated. If the new cell value is higher, the background color shall change to
Answer:
Place the code below into the standard module
Private Sub Worksheet_Calculate()
Dim rng As Range, rngAct As Range
Set rng = Me.UsedRange
With Worksheets("Dummy")
For Each rngAct In rng.Cells
If rngAct.Value < .Range(rngAct.Address).Value Then
rngAct.Interior.ColorIndex = 6
ElseIf rngAct.Value > .Range(rngAct.Address).Value Then
rngAct.Interior.ColorIndex = 3
End If
Next rngAct
.Range(rng.Address).Value = rng.Value
End With
End Sub
Sub OutOfOn()
With Worksheets("Dummy")
If .Visible = True Then .Visible = xlVeryHidden Else .Visible = True
End With
End Sub
Book Store:
Recommended Books:
- The One Page Business Plan: Start With a Vision, Build a Company!
- Microsoft Office Xp: Advanced Concepts and Techniques: Word 2002, Excel 2002, Access 2002, Powerpoint 2002
- Adventure Capitalist: The Ultimate Road Trip
- Financial Shenanigans : How to Detect Accounting Gimmicks & Fraud in Financial Reports
- Analysis of Financial Statements
- Advanced modelling in finance using Excel and VBA
No comments have been submitted.

