Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Filtering a detailed list | Excel Discussion (Misc queries) | |||
How do I create a detailed Timesheet? | Excel Worksheet Functions | |||
Move text data including detailed formatting | Excel Programming | |||
Creating a detailed log file | Excel Programming | |||
VBA Books - Detailed | Excel Programming |