Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Visual Basic/Excel Changing font olor index in part of a string

I wish to change the font color index in part of a string (using visual
basic) in the same fashion that we can change a highlighted part of a string
in the editing bar.

VB seems to require that the characters to have their font color index
changed have to be an entire selected cell.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Visual Basic/Excel Changing font olor index in part of a string

Hi Al,

See VBA help on the Characters object and the Characters property.

The following inserts some text into A1 on Sheet1 and sets the font of
alternate characters to red:

Sub Tester()
Dim i As Long

With Worksheets("Sheet1").Range("A1")
.Value = "ABRACADABRA"
For i = 1 To Len(.Value) Step 2
.Characters(i, 1).Font.ColorIndex = 3
Next
End With
End Sub

---
Regards,
Norman



"Al Gee" <Al wrote in message
...
I wish to change the font color index in part of a string (using visual
basic) in the same fashion that we can change a highlighted part of a
string
in the editing bar.

VB seems to require that the characters to have their font color index
changed have to be an entire selected cell.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Visual Basic/Excel Changing font olor index in part of a string

Hi,

For starters:
ActiveCell.Characters(Start:=1, Length:=5).Font.ColorIndex = 4
The above will make the first 5 characters green.
Adjust Start, Length and ColorIndex as necessary.

regards,
Don

"Al Gee" <Al wrote in message
...
I wish to change the font color index in part of a string (using visual
basic) in the same fashion that we can change a highlighted part of a
string
in the editing bar.

VB seems to require that the characters to have their font color index
changed have to be an entire selected cell.



  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Visual Basic/Excel Changing font olor index in part of a string

hi,
on a play sheet i have, i just color the Changcolors()
part of the sub below to blue. the word sub remain black.
if i understand what you want, the code below with do it.
(tested).
Sub changecolors()
Range("H19").Select
With ActiveCell.Characters(Start:=1, Length:=4).Font
.ColorIndex = xlAutomatic
End With
With ActiveCell.Characters(Start:=5, Length:=14).Font
.ColorIndex = 5
End With
End Sub

-----Original Message-----
I wish to change the font color index in part of a string

(using visual
basic) in the same fashion that we can change a

highlighted part of a string
in the editing bar.

VB seems to require that the characters to have their

font color index
changed have to be an entire selected cell.
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Visual Basic/Excel Changing font olor index in part of a string

If the Cell is A1, then try the following code:

Range("A1").Characters(1, 2).Font.ColorIndex = 5

To change the color of the first 2 chars to blue



Al Gee <Al wrote in message ...
I wish to change the font color index in part of a string (using visual
basic) in the same fashion that we can change a highlighted part of a string
in the editing bar.

VB seems to require that the characters to have their font color index
changed have to be an entire selected cell.

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
Visual Basic 6 - String Reading V Govindan Excel Discussion (Misc queries) 2 December 7th 06 03:56 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
Visual Basic Help Wizard/Index problem, can't get cursor HelpNeeded Excel Discussion (Misc queries) 3 March 4th 05 03:46 AM
changing a formula range in visual basic OoM JaN Excel Programming 1 May 20th 04 07:35 PM
Changing Formula References in Visual Basic EmmaC. Excel Programming 0 March 1st 04 04:08 PM


All times are GMT +1. The time now is 05:48 PM.

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"