excel - Unable to rerun macro after delete the row -


i trying run code validate column "k". if cells in column "k" null error message should pop , cell should turn red. tried following code , working. following issue. run macro. macro detects null cell , pop error msg. deleted row null cell. run macro again. error msg pop again. last cell of column k turn red eventhough row doesnt have data.

this code using

sub errormsg () count2 = range("b:b").specialcells(xllastcell).row n = 2 count2 if range("k" & n).value = vbnullstring range("k" & n).interior.colorindex = 3 msgbox "error ! null value " exit sub end if                   next n end sub  

use column (like id or never going blank) , use in if statement too

sub errormsg () count2 = range("b:b").specialcells(xllastcell).row n = 2 count2     if range("k" & n).value = vbnullstring , range("a" & n).value <> ""         range("k" & n).interior.colorindex = 3         msgbox "error ! null value "         exit sub     end if                   next n end sub  

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -