excel - Type Mismatch, yet functional code -
this macro designed identify string "%" in cell and, if present, identify colouring yellow.
interestingly work, keep getting type mismatch error afterword on line:
if instr(rngcell.value, "%") > 0
this full code below:
public sub markerrorvalues() dim iwarncolor integer dim rng range dim rngcell variant dim lr long dim vval dim trow lr = cells(rows.count, "b").end(xlup).row set rng = range("c1:c" & lr) iwarncolor = xlthemecoloraccent2 each rngcell in rng.cells trow = rngcell.row if instr(rngcell.value, "%") > 0 rngcell.interior.colorindex = iwarncolor else rngcell.interior.pattern = xlnone end if next end sub
any appreciated!
probably have cells error values (eg #ref!
, #div/0!
etc)
to filter these out, wrap troublesome code inside not iserror
conditional:
if not iserror(rngcell.value) if instr(rngcell.value, "%") > 0 rngcell.interior.colorindex = iwarncolor else rngcell.interior.pattern = xlnone end if endif
Comments
Post a Comment