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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -