PC Review


Reply
Thread Tools Rate Thread

Detailed formatting problem

 
 
Brad
Guest
Posts: n/a
 
      30th May 2008
The question: when using the macro below, after the last sentence is bolded
the required format width of the paragraph is exceeded. How can I solve this
problem?

Any improvements on the coding would be appreciated - this has to work in
either versions 2003 or 2007

The detail..

The following six sentences have to be formatted in paragraph form with the
last sentence being bolded.

This illustration assumes an annual premium amount of $10,000.00 based on an
Annual payment mode.
The values shown in the illustration assume that the modal premiums are paid
at the beginning of the payment period.
Any assumed single premium deposits are detailed on page 3 of this
illustration.
The illustration shows total annual premiums assumed.
Values will vary depending on the timing of premium payments.
This illustration shows total premiums assumed and does not differentiate
between premiums paid by the Participant and premiums paid by the employer
(if any).

The first sentence really looks like this
="This illustration assumes an annual premium amount of
"&TEXT(Input!$C$22,"$#,###.00")&" based on
"&VLOOKUP($A$12,InputInfo!$B$45:$C$51,2,FALSE)&"."

where c22 can be any number from 300 to 1,000,000
and the length of the vlookup ranges from 20 to 26 characters

I'm using the following macro

Sub ReformatSentences()
Dim RemainingBold As Integer
Dim SecondSentence As Integer
Dim LastSentence As Integer
Dim rowcnt As Integer

shtPrem.Range("o13:s22").Clear
shtPrem.Range("b13:b18").Copy
shtPrem.Range("o1318").PasteSpecial xlValues

shtPrem.Range("o13:s22").Justify
shtPrem.Range("o13:s22").Font.Bold = False
rowcnt = 12 + shtPrem.Range("o11").Value
RemainingBold = 158
Do
LastSentence = Len(shtPrem.Range("o" & rowcnt))
If LastSentence <= RemainingBold Then
shtPrem.Range("o" & rowcnt).Font.Bold = True
Else
shtPrem.Range("o" & rowcnt).Characters(LastSentence -
RemainingBold, 158).Font.Bold = True
End If
RemainingBold = RemainingBold - LastSentence
rowcnt = rowcnt - 1
Loop While RemainingBold > 0
End Sub

--


Wag more, bark less
 
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
Red X (not same problem as detailed elsewhere) Clubside Microsoft Outlook Discussion 1 3rd May 2008 03:36 AM
Move text data including detailed formatting =?Utf-8?B?QWRyaWFu?= Microsoft Excel Programming 1 15th May 2007 12:28 AM
links to more detailed custom or conditional formatting docs? orbii Microsoft Excel Discussion 3 30th Dec 2006 01:36 AM
Master-Detailed Repeater - Binding Problem Emre Guldogan Microsoft ASP .NET 0 16th Dec 2004 12:41 AM
ListView in detailed view problem. Ronny Microsoft Dot NET 1 9th Dec 2003 06:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 AM.