Excel: How do I insert different colors in same cell?
Hi
I need to be able to display one or more colors within a
cell in Excel.
Ultimately it would be nice to also be able to put in a number
within each color in the cell as well.
(Note: I would like to insert one or more uniform square or rectangular color in the same cell. Optionally with some text within the colored square/reqtangular shape.)
I'm hoping I can use one or more object or something else to
represent the colors. If that is not possible then maybe some other solution.
I must be able (using VBA) to check what colors that currently exist within a given cell.
I also need to create the colored object(s) using VBA.
Would be nice if I could do this without having to use premade images or whatever.... hope I can do this just by using VBA.
Anybody with a clue on how I do that.
Last edited by bongobongo; Jun 12th, 2006 at 12:44 PM.
Re: Excel: How do I insert different colors in same cell?
Welcome to the Forums
Excel can only display one colour at any given time within any given cell. So your options are:
Use more than one cell to represent a "cell". Why does it have to be an individual cell? Could 4 Excel cells represent one "cell", for example? This is easily accomplished in VBA.
Use objects such as pictureboxes or labels and position them within the cell. This will be very much of a nuisance, because positioning them in the first place will be difficult, they won't scale or size properly if you adjust the cells. This method is also relatively easy to set up in VBA, but more difficult to do anything with afterwards.
Could you elaborate on why you need this, so that we can put it into perspective and figure out what you're after?
Re: Excel: How do I insert different colors in same cell?
Hi.
I cannot use multiple cells to reprecent one cell, unless I can create multiple
cells within another cell..... probably not very doable though... :-)
Pictureboxes and labels.... maybe, have to look into that.
Is there any other options..
Have looked through all the font characters and found some squares that might be usable, since they are characters I can set the color..... so allmost there but this will not enable me to get a square colored box with a number within...
Re: Excel: How do I insert different colors in same cell?
Well, I'm not able to do that because:
A cell higher up in the colum are related to the color(s) set for zero, one or more cells further down, in the same column.
I might be able to do what I want using some special characters, but then it would be nice being able to be able to create a custom attribute for the characters to be used.
Is it possible to create one or more custom attribute(s) for either the inserted character(s) (which actually looks like colored squares), or eventually some attribute for the cell that I could use to store data related to each of the inserted characters in the cell?
Example:
When I insert a character (colored square) in a cell I also want to attach at least one, and hopefully two short strings to the character, that I can fetch anytime laiter. If not possible to create custom attributes for a character then I might be able to store the extra string(s) in an attribute for the cell.
Re: Excel: How do I insert different colors in same cell?
Not ideal to do using custom characters, because they are effectively just strings. You would need to append cells to each row telling you what the characters mean for that row.
I still have no idea what it is that you're trying to accomplish - some of us may be able to come up with still different (and possibly better) ways of going about it if you tell us what the objective is rather than your way of going about the problem.
Re: Excel: How do I insert different colors in same cell?
Wakey Wakey, I'm sure you're all asleep and have long lost interest in this post however... for multiple fonts/colours etc in a single cell you use the cells(x,y).characters(start,length).font function
The following code makes the first 10 characters BOLD and colour 56 and the rest not bold and colour 12
With Cells(row,col).Characters(start:=1, Length:=10).Font
.FontStyle = "Bold"
.ColorIndex = 56
End With
With Cells(col,row).Characters(start:=11, Length:=180).Font
.FontStyle = "Normal"
.ColorIndex = 12
End With
Re: Excel: How do I insert different colors in same cell?
Almost a year after last post but thank you. This was really useful. The point of these forums after solving the problem for the original poster is to help others.
So here is my solution, it may help you.
What I needed was a way to code the contents of the cell. Each color ment a different location of the inventory, but I needed that to be on one cell. Since there are only 3 different locations I made a sub that cycles through the options:
* NOTE1: color 3 is always red since it is only relevant if there are 3 characters on the cell
* NOTE2: colors 1 and 2 cycle from Green/Blue to Green/Red to Blue/Red. No other combination is necesary.
* NOTE3: this works on the current cell, I asigned the macro to a key combination.
Last edited by kaliman79912; Mar 2nd, 2011 at 05:37 PM.
More important than the will to succeed, is the will to prepare for success.
Please rate the posts, your comments are the fuel to keep helping people