excel - VBA If cell is under a certain length, highlight and display message -


i'm trying write macro examines column in excel spreadsheet looking entries shorter 9 characters greater 2, , if found, display message , highlight cell in value found. might happen multiple times. have written following code:

sub highlight() dim c range dim lr integer dim intcell long lr = worksheets("basket").cells(rows.count, 6).end(xlup).row intcell = 1 8 each c in range("g20:g" & lr).cells     if len(c.value) < 9 , len(c.value) > 2     msgbox "one or more of codes invalid.  correct highlighted values."     c.cells(intcell).interior.color = vbyellow     end if next next end sub 

i can't figure out i'm doing wrong. appreciated.

just guessing @ want highlight

sub highlight() dim c range dim lr integer dim numprobs long dim sht worksheet  set sht=worksheets("basket")  numprobs=0 lr = sht.cells(rows.count, "g").end(xlup).row each c in sht.range("g20:g" & lr).cells     if len(c.value) < 9 , len(c.value) > 2         c.entirerow.cells(1).resize(1,8).interior.color = vbyellow         numprobs=numprobs+1     end if next  if numprobs>0     msgbox "there issues " & numprobs & " rows. see yellow cells" end if    end sub 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -