Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Detailed formatting problem

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("o13:o18").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
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
Filtering a detailed list PJ O'Mahony Excel Discussion (Misc queries) 5 February 9th 09 01:17 PM
How do I create a detailed Timesheet? pangie Excel Worksheet Functions 1 June 22nd 07 06:39 PM
Move text data including detailed formatting Adrian Excel Programming 1 May 15th 07 12:28 AM
Creating a detailed log file [email protected] Excel Programming 1 May 10th 07 11:02 PM
VBA Books - Detailed Arifi Koseoglu Excel Programming 4 February 27th 04 01:25 PM


All times are GMT +1. The time now is 12:38 AM.

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"