vba - Visual basic macro- changing the colour of specific text -


im new visual basic , macros. have been trying create macro through whole document , check see if of font red;if red want change red font white font.

i know code wrong can tell me doing wrong?

sub red()    if font.color =wdcolorred   font.color = -603914241 end sub 

you can use following quick (no looping required each sheet).

sub macro1() application.screenupdating = false 'disable screen updating, i.e, avoid excel redrawing screen after each color change make application.findformat.font.color = 255 application.replaceformat.font.color = 16777215 cells.select selection.replace what:="", replacement:="", matchcase:=false, searchformat:=true, replaceformat:=true application.screenupdating = true 'enable screen updating end sub 

font colors can little tricky. find out color want, select cell , change color color need know number for. go developer screen , view -> immediate window (or hit ctrl+g). in immediate window (should @ bottom of screen, cell has color want know still selected, type

? selection.font.color 

and give color interested in. put numbers in application.find/replaceformat.font.color above.

this work sheet selected, can throw in loop , iterate on sheets in workbook change them all.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -