This is actually an improvement for this previous topic.
Context:
Excel 2003, Windows 7 Professional SP1.
- Working on workbook A, which contains a cell with conditional formatting calling a personal function. This function refers to a defined name of workbook A.
- Workbook B is opened or edited (not only activated). It can be any workbook.
- We activate back workbook A.
Problem:
The conditional formatting causes various bugs if workbook B's window overlaps workbook A's. In other words, when at some point workbook A gets behind workbook B.
Depending on the window state (whether Excel is in full screen or not, whether ActiveWindow.WindowState = xlNormal
or xlMaximized
, whether the window is narrow or wide ...), the bugs can be :
Mainly: cells calling personal (volatile) functions that refer to defined names don't calculate when switching back to workbook A. This is a huge problem, as I need to force calculation with Ctrl+Alt+F9.
Display bugs often occur, notably when workbooks A and B are floating next to each other, overlapping each other. Cell content vanish, ghosts cells of the ones with conditional formatting appear, the screen freezes, window border trails (W98 style) are displayed when trying to move around one of the workbooks ...
In
Workbook_Activate
of workbook A, breakpoints don't stop the code (thoughdebug.print
andMsgBox
work) and you can't useApplication
orActiveWindow
methods.Application.CalculateFull
sometimes causes all the cells' content to disappear until they are selected (using Ctrl+A, for example).
How to solve or avoid this problem?
I will answer to myself below, if it can be of some interest for anyone!