Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Styles on Ribbon Stephen J Excel Discussion (Misc queries) 1 April 14th 10 08:13 AM
some unknown Cell styles are shown in cell styles Vaibhav Dhawade Excel Worksheet Functions 0 March 6th 10 05:11 AM
Excel Cell Styles - Quick Styles? Dean@DCF Excel Discussion (Misc queries) 0 November 15th 07 10:40 PM
New Cell Styles Steve... New Users to Excel 4 April 1st 07 04:56 PM
count cell styles Ecco Excel Programming 0 July 22nd 03 11:45 AM


All times are GMT +1. The time now is 04:31 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"