ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   String Manipulation within VBA (https://www.excelbanter.com/excel-discussion-misc-queries/121625-string-manipulation-within-vba.html)

BillCPA

String Manipulation within VBA
 
In VBA, you can use the .Characters(...).Font statement to change the Name,
FontStyle, Size, etc. of individual characters in a cell. Is there any way
to do the same with a character string in VBA without first placing it into a
cell?

Example - in the string "ABCDEFG", if I want the 'B' to be green, the 'D' to
have a font size of 12, and the 'F' to have the font name 'Symbol', I can put
the string into a cell and then set the individual characters. But can I
take the string inside VBA and do the same, without first placing it into a
cell?


--
Bill @ UAMS

Wood Grafing

String Manipulation within VBA
 
I would record a macro of myself making the changes in the cell, and then
examine that code in VBA...

"BillCPA" wrote:

In VBA, you can use the .Characters(...).Font statement to change the Name,
FontStyle, Size, etc. of individual characters in a cell. Is there any way
to do the same with a character string in VBA without first placing it into a
cell?

Example - in the string "ABCDEFG", if I want the 'B' to be green, the 'D' to
have a font size of 12, and the 'F' to have the font name 'Symbol', I can put
the string into a cell and then set the individual characters. But can I
take the string inside VBA and do the same, without first placing it into a
cell?


--
Bill @ UAMS


Jon Peltier

String Manipulation within VBA
 
You can't apply any of these properties to a string in VBA, it's basically
just a string of ASCII values. You have to put the string into the cell, so
that you have an object (a character in a cell is an object) with properties
to manipulate.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"BillCPA" <Bill @ UAMS wrote in message
...
In VBA, you can use the .Characters(...).Font statement to change the
Name,
FontStyle, Size, etc. of individual characters in a cell. Is there any
way
to do the same with a character string in VBA without first placing it
into a
cell?

Example - in the string "ABCDEFG", if I want the 'B' to be green, the 'D'
to
have a font size of 12, and the 'F' to have the font name 'Symbol', I can
put
the string into a cell and then set the individual characters. But can I
take the string inside VBA and do the same, without first placing it into
a
cell?


--
Bill @ UAMS





All times are GMT +1. The time now is 07:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com