vba - Change Font Of Multiple Sub Strings in Excel Cell -


i have font show specific symbols. typed sheet standard/default font. i'm able identify these characters , change these characters' font symbol font, having trouble making work correctly when there more 1 identified symbol in cell.

for example , cell may contain:

this value x , y, , z

i need change font of x, y, , z.

here how changing characters' font via vba:

sub insertfont(insertrange range, symboltext string, symbolposition integer)     dim celltext string     dim newvalue string     celltext = insertrange.value2     newvalue = replace(celltext, symboltext, symboldict.item(symboltext), 1, 1)     insertrange.value2 = newvalue     insertrange.characters(symbolposition, len(symboldict.item(symboltext))).font         .name = "myfont"     end  end sub 

the problem after each font change, rest of cell returns default font! how can font changes stick of changes?

end result:

this value x , y, , ☹

per suggestion of @timwilliams via comments, here's solution works:

sub insertsymbol(insertrange range, symboltext string, symbolposition integer)      dim celltext string     dim newvalue string     insertrange.characters(symbolposition, len(symboltext)).delete     insertrange.characters(symbolposition, 0).insert symboldict.item(symboltext) '2nd parameter 0 not overwrite characters     insertrange.characters(symbolposition, 1).font.name = "my symbol font name"  end sub 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -