'Now we loop through rColumn, and the address of every cell Set rColumn = Range(rColumn, rColumn.End(xlDown)) 'If cell C3 isn't empty, we expand the range down to 'First we define our range as cell C2 to the first Now you must insert a VBA module (menu "Insert" and "Module") and insert the following code: MsgBox Err.Description & " Procedure Worksheet_Change." If Range("C2").Value = 0 And bCellCheck = True Then 'If the value of C2 is negative and not blinking already 'standard module, where the range variable rRange is 'The procedures StartBlink and StopBlink are in a 'Change the condition and the cell as you like. 'If the value changes and becomes greater than zero, 'if the value in cell C2 is lower than zero, and if 'In this example the procedure Startblink is called 'procedure, which is called if a cell or a range 'where events on the sheets can execute some code 'Every sheet in a workbook has its own VBA code sheet, Private Sub Worksheet_Change(ByVal Target As Excel.Range) If you are viewing this page on a device with a small screen, some code lines may break/wrap, but if you copy and paste into the VBA editor, the linebreaks should be okay. Highlight the following code with the mouse, copy (CTRL+C) and paste (CTRL+V) into the sheet's code sheet. If you can't see them, you must open Project Explorer (CTRL+R). Open Excel's VBA editor (ALT+F11) and double click on one of the worksheets' code sheet. If the value becomes negative, the cell will blink with a red colour. Imagine that cell A2 represents your income, cell B2 your expenses and in C2 we deduct expenses from income. The following example will make cell C2 blink with a red colour, if the value changes to negative. It is zipped, and you can unxip it by right-clicking and select "extract," or whatever Windows suggests. You can download a spreadsheet with the example here. In the first example we make only one cell blink in the other example it can be several cells in a range. In the examples below we make use of the Worksheet_Change proceduren that executes automatically, when a cell or a range is changed in the sheet, and this also happens if the colour of a cell changes. It is not unlike conditional formatting, but conditional formatting cannot make cells blink - at least not in the old Excel versions I use.Įvery sheet in an Excel spreadsheet has a VBA code sheet, where you can put some standard procedures that are called automatically, if certain events happen on the sheet. The examples also show, how VBA's OnTime function can be used to "plan" execution of a procedure at a given time. On this page I show, how a macro can make one or more cells blink automatically, if the cell content doesn't meet a condition, and how the blink stops, if the cell value is changed to something okay. Blinking cells in Excel and the OnTime function
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |