Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Different Styles within a single Cell
Hi!
I would like a vb function to set a value into a cell, as well as different styles within this cell. For example, I would like to have in cells(1,1) the value "AB" where A would be normal, and B would B bold (or another Font, another color, etc) How do I do that from VB ? Thanks! |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Different Styles within a single Cell
Hi Jeremie,
for example: With ActiveCell.Characters(Start:=2, Length:=1).Font .FontStyle = "Bold" End With Maybe the most convenient way is to record a macro to see properies and their values with different styles. Regards, Ivan |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Different Styles within a single Cell
Thanks Ivan, that's just great!
And quick! Best Jérémie "Ivan Raiminius" schrieb im Newsbeitrag ups.com... Hi Jeremie, for example: With ActiveCell.Characters(Start:=2, Length:=1).Font .FontStyle = "Bold" End With Maybe the most convenient way is to record a macro to see properies and their values with different styles. Regards, Ivan |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Different Styles within a single Cell
Sub gsnu()
Cells(1, 1) = "AB" Cells(1, 1).Characters(Start:=1, Length:=1).Font.ColorIndex = 32 End Sub will paint the first character blue. By specifying start and length each, character can be assigned a different style -- Gary's Student "Jérémie Gent" wrote: Hi! I would like a vb function to set a value into a cell, as well as different styles within this cell. For example, I would like to have in cells(1,1) the value "AB" where A would be normal, and B would B bold (or another Font, another color, etc) How do I do that from VB ? Thanks! |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Different Styles within a single Cell
Thanks!
I noticed following behaviour though: If I concatenate a string to the value of the cell, then the formatings of the characters aren't kept. For example, if I have AB with the B in blue like in your code Gary, then as soon as I do something like cells(1,1).value=cells(1,1).value & "C" then the whole text ABC is in blue Just as Information, doesn't bother me though. I changed my procedure to generate first the whole text content of the cell, then the formatting inside. It works fine now. Cheers Jérémie "Gary''s Student" schrieb im Newsbeitrag ... Sub gsnu() Cells(1, 1) = "AB" Cells(1, 1).Characters(Start:=1, Length:=1).Font.ColorIndex = 32 End Sub will paint the first character blue. By specifying start and length each, character can be assigned a different style -- Gary's Student "Jérémie Gent" wrote: Hi! I would like a vb function to set a value into a cell, as well as different styles within this cell. For example, I would like to have in cells(1,1) the value "AB" where A would be normal, and B would B bold (or another Font, another color, etc) How do I do that from VB ? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cell Styles on Ribbon | Excel Discussion (Misc queries) | |||
some unknown Cell styles are shown in cell styles | Excel Worksheet Functions | |||
Excel Cell Styles - Quick Styles? | Excel Discussion (Misc queries) | |||
New Cell Styles | New Users to Excel | |||
count cell styles | Excel Programming |