VBA String color built based on value

Myrko

Board Regular
Joined
Jan 26, 2015
Messages
77
Hi,

I am working on a translation of part numbers from provider's to my company's standards.

Provider's part numbers contain several words/numbers divided with spaces (all in one cell) - and my code translate them word by word by using vlookups from other sheet.

So, the part number (product of translation from provider's PN) is being built in the code by adding word by word.

I want specific words to be of different color / bold font.

Example:

NewPN = Translation1 & " " & Translation2(RedColor) & " " & Translation3(Bold) & " " & Translation4

Is it possible to build string with specific color of parts (by adding specifications of the font in an example code above) or does it require to be handled in another way? I've found some solutions which apply color change to an existing content of a cell but I was trying to figure out if this can be done as part of translation - one process and not two processes (translation and adding value to a cell, then manipulating the formatting of font)?

If you need more details, let me know. I've last minute changed way to explain the problem and forgot to update Subject - in general the translations that need to be colored differently will be specific values (such as "-") but I didn't want to make it too complicated as I would know how to deal that conditional part - the problem I don't know to solve currently is around manipulating the color.

Thanks for support in advance!
 
Last edited:

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Formula results can't have various colors -- one color results only.
You can only have various colors in constants.
 
Upvote 0
Thanks BobUmlas for quick response. Does that mean that I need to manipulate the color after the whole translation is completed?
 
Upvote 0
Different colored letters are set after the string is put in a cell. (Unlike PET ASCII, there are no color characters built into an excel string.)
You would have to use VBA and build the string, noting the characters locations when you want the colors to change, put the string into a cell and then use that noted informtion to change the .Characters .Font.Color property of that cell.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top