Hello,
I always use standard colors in my xl applications.
The macro colorConventions below applies the standards to the activeSheet.
It works correctly without any perturbing screen animation thanks to the statement "Application.ScreenUpdating = False"
The next macro colorConventions2 below does the same for a complete activeWorkbook.
It does the job.
But unfortunately, it comes with perturbing screen animations.
Apparently the statement "xl.ScreenUpdating = False" is not effective.
Any clue ?
I always use standard colors in my xl applications.
The macro colorConventions below applies the standards to the activeSheet.
It works correctly without any perturbing screen animation thanks to the statement "Application.ScreenUpdating = False"
The next macro colorConventions2 below does the same for a complete activeWorkbook.
It does the job.
But unfortunately, it comes with perturbing screen animations.
Apparently the statement "xl.ScreenUpdating = False" is not effective.
Any clue ?
Rich (BB code):
Sub colorConventions()
On Error Resume Next
Application.ScreenUpdating = False
Set currentSel = Selection
Err.Clear
ActiveSheet.Cells.SpecialCells(xlCellTypeFormulas, xlNumbers).Select
If Err = 0 Then Selection.Font.ColorIndex = 3
Err.Clear
ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, xlTextValues).Select
If Err = 0 Then Selection.Font.ColorIndex = 5
Err.Clear
ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, xlNumbers).Select
If Err = 0 Then Selection.Font.ColorIndex = 50
If ActiveWindow.GridlineColorIndex = 24 Then
ActiveWindow.GridlineColorIndex = 0
ActiveWindow.DisplayGridlines = False
Else
ActiveWindow.GridlineColorIndex = 24
ActiveWindow.DisplayGridlines = True
End If
Dim pt As PivotTable
For Each pt In ActiveSheet.PivotTables
pt.ColumnRange.Font.ColorIndex = 5
pt.RowRange.Font.ColorIndex = 5
pt.DataLabelRange.Font.ColorIndex = 5
pt.DataBodyRange.Font.ColorIndex = 50
Next pt
currentSel.Select
Application.ScreenUpdating = True
End Sub
Rich (BB code):
Sub colorConventions2()
On Error Resume Next
Set xl = Application
Set ThisRecipeWorkbook = ActiveWorkbook
xl.ScreenUpdating = False
Set curSh = xl.ActiveSheet
For Each sh In ThisRecipeWorkbook.Worksheets
If sh.Visible Then
sh.Select
Set currentSel = xl.Selection
Err.Clear
sh.Cells.SpecialCells(xlCellTypeFormulas, xlNumbers).Select
If Err = 0 Then xl.Selection.Font.ColorIndex = 3
Err.Clear
sh.Cells.SpecialCells(xlCellTypeConstants, xlNumbers).Select
If Err = 0 Then xl.Selection.Font.ColorIndex = 50
Err.Clear
sh.Cells.SpecialCells(xlCellTypeFormulas, xlTextValues).Select
If Err = 0 Then xl.Selection.Font.ColorIndex = 5
Err.Clear
sh.Cells.SpecialCells(xlCellTypeConstants, xlTextValues).Select
If Err = 0 Then xl.Selection.Font.ColorIndex = 5
ActiveWindow.GridlineColorIndex = 0
ActiveWindow.DisplayGridlines = False
For Each pt In sh.PivotTables
pt.ColumnRange.Font.ColorIndex = 5
pt.RowRange.Font.ColorIndex = 5
pt.DataLabelRange.Font.ColorIndex = 5
pt.DataBodyRange.Font.ColorIndex = 50
Next pt
currentSel.Select
End If
Next sh
curSh.Activate
xl.ScreenUpdating = True
End Sub