Friday 15 January 2010

vba - Change the font of specific words in cells -



vba - Change the font of specific words in cells -

i trying alter font of specific words in range of cells. in range of a2:q1000, if word risk or high in cell, font should alter reddish , bold. below code set far.

sub font_change() dim ddata range dim name string set ddata = sheets("sheet1").range("a2:q10000") each cell in ddata if cell = "risk" cell.font.color = 2 cell.font.bold = true elseif cell = "medium" cell.font.bold elseif cell = "hign" cell.font.color = 2 cell.font.bold = true end if next end sub

try this:

sub tests() each cell in range("a2:q1000") if ucase(cell.value) "*risk*" or ucase(cell.value) "*high*" cell.font.color = vbred cell.font.bold = true end if if ucase(cell.value) "*medium*" cell.font.color = vbred next cell end sub

vba

No comments:

Post a Comment