Conditional Formatting and re-evaluate
All,
I have read JRD's post on COnditional formatting. It is very useful. However the VBA doesn't recalculate a cell's formatting until it is changed. Therefore if you require a change in any of the values that cause a change, the cells that had been formatted based on your previous values stay with their previous formatting. I need a way to check all cells at the opening of a sheet (at a minimum) and recheck all the cells for the proper value using the conditional formatting code. thanks for all your help on Yahoo JRD. BTW JRD suggested this code
Private Sub Workbook_Open()
Dim Cel As Range For Each Cel In Sheets("Sheet1").UsedRange Cel.Value = Cel.Value NextEnd Sub
or something similar. Although I think it is malformed due to using IM as the medium. Can anyone help?
thanks
-Justin
Help with setting up this code and calling it on OPEN and CHANGE
Private Sub Workbook_Open()
Call Reformat
End Sub
On calling Reformat from Workbook_Open
---------------------------
Microsoft Visual Basic
---------------------------
Compile error:
Expected variable or procedure, not module
---------------------------
Code and simplification question
DRJ was kind enough to give me the following code to place in worksheet_Change. It works wonderfully. all I wanted was to acheive the same function but not only during a cell change but also on workbook_open. Oh and prefereably on every sheet not just the sheet the code is attached to. Sorry I am new to this and my previous posts have been poorly described. I am getting a book on VBA in the mail though so I won't suck forever :-)
[VBA]Option Compare Text 'A=a, B=b, ... Z=z
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
Dim Rng1 As Range
On Error Resume Next
Set Rng1 = ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, 1)
On Error GoTo 0
If Rng1 Is Nothing Then
Set Rng1 = Range(Target.Address)
Else
Set Rng1 = Union(Range(Target.Address), Rng1)
End If
For Each Cell In Rng1
Select Case Cell.Value
Case vbNullString
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
Case "Tom", "Paul", "John"
Cell.Interior.ColorIndex = 3
Cell.Font.Bold = True
Case "Smith", "Jones"
Cell.Interior.ColorIndex = 4
Cell.Font.Bold = True
Case 1, 3, 7, 9
Cell.Interior.ColorIndex = 5
Cell.Font.Bold = True
Case 10 To 25
Cell.Interior.ColorIndex = 6
Cell.Font.Bold = True
Case 26 To 99
Cell.Interior.ColorIndex = 7
Cell.Font.Bold = True
Case Else
Cell.Interior.ColorIndex = xlNone
Cell.Font.Bold = False
End Select
Next
End Sub
[/VBA]