ID: Q156892
The information in this article applies to:
When you specify a conditional format that refers to a user-defined function, the Microsoft Excel screen may stop updating or may be redrawn incorrectly, or Microsoft Excel may stop responding.
This problem may occur when both of the following conditions are true:
-and-
To get your screen to refresh correctly, save and close the workbook. If the screen does not update correctly after closing the workbook, follow these steps:
1. Quit Microsoft Excel.
2. Open the workbook.
3. Remove the conditional formatting that refers to the user-defined
function.
4. Save the workbook.
NOTE: In some cases, simply removing the message box from the function may work as expected.
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article.
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:
http://www.microsoft.com/support/supportnet/refguide/
The following example creates a user-defined function and a conditional format that refers to this function.
1. Close all workbooks you currently have open in Microsoft Excel.
2. Open a new workbook.
3. Start Visual Basic Editor (press ALT+F11).
4. Type the following function into the new module sheet:
Function aTest()
aTest = 1
MsgBox aTest
End Function
5. On the File menu, click "Close and Return to Microsoft Excel."
6. In Sheet1, type "1" (without the quotation marks) in cell A1.
7. With cell A1 selected, click Conditional Formatting on the Format
menu.
8. In the Condition 1 list, click "Cell Value Is."
9. In the next list, click "equal to."
10. In the RefEdit box, type "=aTest()" (without the quotation marks).
11. Click Format. In the Color list, click Red, and then click OK.
12. In the Conditional Formatting dialog box, click OK.
The message box appears several times, and the screen stops updating the display. However, menus are still available.
For more information about conditional formatting, click the Index tab in Microsoft Excel Help, type the following text
conditional formats
and then double-click the selected text to go to the "Highlight data that
meets conditions you specify" topic.
For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q163435
TITLE : VBA: Programming Resources for Visual Basic for
Applications
Additional query words: XL97 XL98 8.00 hang hangs lock crash crashes freeze
freezes
Keywords : kbenv kbprg kbdta kbdtacode xlui xlformat KbVBA kbfaq
Version : WINDOWS:97; MACINTOSH:98
Platform : MACINTOSH WINDOWS
Issue type : kbbug
Last Reviewed: May 19, 1999