PC Review


Reply
Thread Tools Rate Thread

Can I change the format of numerical & specific word referenceswithin a cell?

 
 
RJQMAN@gmail.com
Guest
Posts: n/a
 
      27th Jun 2008
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?
 
Reply With Quote
 
 
 
 
RJQMAN@gmail.com
Guest
Posts: n/a
 
      27th Jun 2008
On Jun 27, 10:59*am, "RJQ...@gmail.com" <RJQ...@gmail.com> wrote:
> 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?


I was able to find code written by another person on this group that
solved 90% of my problem - I can now search for the specific words,
change them to bold face, and underline them. However the code only
finds the first usage of the word in the paragraph. For example, I
want to underline and make bold the year 2009 in the following
statement;

In April 2008 until April 2009.

The code will catch the 1st 2009 but not the 2nd one. I am thinking
(always a risky thing to do). that if the code could somehow overlook
the text after it has been changed to bold, I could put the entry in
two or three times, and it would work, but I have no idea how to do
that. Perphaps there is a better solution. Can anyone help? Here is
the code that works so far;

Public Sub UnderlineInRed2()
Dim myArr As Variant
Dim i As Integer
Dim foundCell As Range
Dim foundAddr As String
Dim startPos As Integer

Sheets("Edit Page").Select


myArr = Array("January", "February", "March", "April", "May", "2008",
"2009")
' I omitted the other months and years here for clarity

For i = 0 To UBound(myArr)
Set foundCell = Columns("F:G").Find(what:=myArr(i), _
LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)
If Not foundCell Is Nothing Then
foundAddr = foundCell.Address
Do
With foundCell
startPos = InStr(UCase(.Text), UCase(myArr(i)))
With .Characters(startPos, 4).Font
.Underline = True
.Bold = True
End With
End With
Set foundCell = Columns("F:G").FindNext(After:=foundCell)
Loop While Not foundCell Is Nothing And _
foundCell.Address <> foundAddr
End If
Next i
End Sub
 
Reply With Quote
 
RJQMAN@gmail.com
Guest
Posts: n/a
 
      28th Jun 2008
On Jun 27, 6:27*pm, "RJQ...@gmail.com" <RJQ...@gmail.com> wrote:
> On Jun 27, 10:59*am, "RJQ...@gmail.com" <RJQ...@gmail.com> wrote:
>
>
>
>
>
> > I am using the program to construct a document. *When the document is
> > completed, eachcellcontains a paragraph. *The program works well.
> > However, I would like to be able to go inside eachcelland change the
> > format whenever there is a dollar value shown from standard format to
> >boldface 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 thecell, after constructing and pasting
> > in thecell, 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"boldface and underline, as well as
> > $550.00boldface and underline, and "May 2009"boldface 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 thecell, 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 thecelland 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?

>
> I was able to find code written by another person on this group that
> solved 90% of my problem - I can now search for the specific words,
> change them toboldface, and underline them. *However the code only
> finds the first usage of thewordin the paragraph. *For example, I
> want to underline and makeboldthe year 2009 in the following
> statement;
>
> In April 2008 until April 2009.
>
> The code will catch the 1st 2009 but not the 2nd one. *I am thinking
> (always a risky thing to do). that if the code could somehow overlook
> the text after it has been changed tobold, I could put the entry in
> two or three times, and it would work, but I have no idea how to do
> that. *Perphaps there is a better solution. *Can anyone help? *Hereis
> the code that works so far;
>
> Public Sub UnderlineInRed2()
> Dim myArr As Variant
> Dim i As Integer
> Dim foundCell As Range
> Dim foundAddr As String
> Dim startPos As Integer
>
> Sheets("Edit Page").Select
>
> myArr = Array("January", "February", "March", "April", "May", "2008",
> "2009")
> ' I omitted the other months and years here for clarity
>
> For i = 0 To UBound(myArr)
> * * Set foundCell = Columns("F:G").Find(what:=myArr(i), _
> * * * * LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)
> * * If Not foundCell Is Nothing Then
> * * * * foundAddr = foundCell.Address
> * * * * Do
> * * * * * * With foundCell
> * * * * * * * * startPos = InStr(UCase(.Text), UCase(myArr(i)))
> * * * * * * * * With .Characters(startPos, 4).Font
> * * * * * * * * * * .Underline = True
> * * * * * * * * * * .Bold= True
> * * * * * * * * End With
> * * * * * * End With
> * * * * * * Set foundCell = Columns("F:G").FindNext(After:=foundCell)
> * * * * Loop While Not foundCell Is Nothing And _
> * * * * * * * *foundCell.Address <> foundAddr
> * * End If
> Next i
> End Sub- Hide quoted text -
>
> - Show quoted text -


oops - I wrote that wrong

It should have said that the code would catch the first "April" but
not the 2nd one.
Can anyone help?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change format for an individual word in a cell jaysan3 Microsoft Excel Misc 1 28th Aug 2009 11:03 AM
How to change column format? numerical not alphabetical ISco Microsoft Excel Misc 3 12th Dec 2007 07:35 PM
how can I format a cell to change on a specific date =?Utf-8?B?WkM=?= Microsoft Excel New Users 2 16th Sep 2007 01:07 AM
find word in a cell then change cell format motopoyo@spymac.com Microsoft Excel Programming 2 23rd May 2005 01:21 PM
Can I set the numerical type of Cell to Hex format hon123456 Microsoft Excel Misc 2 13th Jan 2005 01:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:33 PM.