vba - Call a sub when a cell is a certain value -


i call sub causes cell blink between red , white if value of cell n63 = 0. in other words, if cell d70 = 0 startblinking else stopblinking.

here bliking sub

option explicit  public nextblink double 'the cell want blink public const blinkcell string = "sheet1!d70"  'start blinking public sub startblinking()     application.goto range("a1"), 1     'if color red, change color , text white     if range(blinkcell).interior.colorindex = 3         range(blinkcell).interior.colorindex = 0         range(blinkcell).value = "white"     'if color white, change color , text red     else         range(blinkcell).interior.colorindex = 3         range(blinkcell).value = "red"     end if     'wait 1 second before changing color again     nextblink = + timeserial(0, 0, 1)     application.ontime nextblink, "startblinking", , true end sub  'stop blkinking public sub stopblinking()     'set color white     range(blinkcell).interior.colorindex = 0     'clear value in cell     'range(blinkcell).clearcontents     on error resume next     application.ontime nextblink, "startblinking", , false     err.clear end sub 

here if not work:

    if worksheets("sheet1").range("n63").value = 0         call startblink()     else         call stopblink()     end if 

how call these 2 subs?

by taking advantage of worksheet_change event can run code each change particular range. below example tailored use-case:

private sub worksheet_change(byval target range)     dim keycells range      ' variable keycells contains cells     ' cause alert when changed.     set keycells = range("d70")      if not application.intersect(keycells, range(target.address)) nothing         if keycells.value = 0              startblinking         else              stopblinking         end if     end if end sub 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -