View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] RJQMAN@gmail.com is offline
external usenet poster
 
Posts: 46
Default Can I change the format of numerical & specific word referenceswithin a cell?

I am using the program to construct a document. When the document is
completed, each cell contains a paragraph. The program works well.
However, I would like to be able to go inside each cell and change the
format whenever there is a dollar value shown from standard format to
bold face and underline. I would, ideally, also like to change the
format when I state a month (January - December) and when a year
appears (2009, 2010, etc).

For example, the sentence in the cell, after constructing and pasting
in the cell, could read;

"The rent for the month of April 2009 is $550.00 payable on the last
day of May 2009."

I would like to make "April 2009" bold face and underline, as well as
$550.00 bold face and underline, and "May 2009" bold face and
underline.

When I started this project, I was doing this by having the program
count the characters in the sentences and adding them together, to
calculate the place to start the format change, sort of like this...

With ActiveCell.Characters(Start:=StartPoint1,
Length:=LengthUnderline1).Font
.Bold = True
.Underline = True
End With

This worked fine, and I used the concept countless times, calculating
the starting and ending points of the format change based on the
sentences constructed and inserted into the paragraph.

However, the options in constructing the paragraph have grown beyond
my wildest imagination, and there are now so many ways that the user
can construct multiple sentences within the cell, that the counting
the characters method is a daunting program challenge.

I would like, if possible, to simply find the words in the paragraph
which was constructed and placed in the cell and change the format
when those words appear. The words would always be the name of a
month, and the numbers would always be dollars. Visual Basic is fine,
as the program is based on macros.

Is there a way to do this that is less cumbersome than counting the
characters before and the length thereof?