Excel VBA - Append text to cell while keeping the cell's already changed text colors -


i'm running comparisions between data in 2 cells (ex. cell a1 & cell b1). add results 'compared' cell.

  • if added (new) in b1, add value 'compared' cell , color value green
  • if exists in both, add value 'compared' cell , color value black
  • if exists in a1 (removed in b1), add value 'compared' cell , color value red.

this works, each time add new cell, cell not maintain colors of changed text.

i use following add next item cell, , color item.

comparedcell.value = comparedcell & "|" & mystringtoappend comparedcell.characters(len(comparedcell) + 2, len(mystringtoappend)).font.color = rgb(0, 255, 0) 

is there way add append colored text without resetting i've colored in cell?

currently testing length of comparedcell after have appended, include appended text.

try using instrrev() find last pipe character "|" entered , work there.

something this:

comparedcell.value = comparedcell & "|" & mystringtoappend comparedcell.characters(instrrev(comparedcell, "|") + 1, len(mystringtoappend)).font.color = rgb(0, 255, 0) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -