![]() |
|
![]() |
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
![]()
Hi,
Look at this image 18.png I have a list of references (bibliography) at the end of the document, which sorted alphabetically I want to organize them in a professional way and put them in subgroups by inserting the corresponding letter before each group of references of a certain letter. The above image is created manually For example: I want to search for the first occurrence of letter A in beginning of the first paragraph which starts with A letter, then insert letter A before this paragraph and apply the style "BibloChar" to it, which is present in the attachment file. When A is finished jump to the B letter and do the same thing, and so and so, until finishing all characters. I want the template of the code for letters A, B, and C, then I will complete the rest of the code. Thanks a lot. |
#2
|
||||
|
||||
![]()
This looks like it works.
Code:
Sub AddLetterHeads() Dim iPar As Integer, sLett As String, aRng As Range, sPrev As String Set aRng = ActiveDocument.Range For iPar = aRng.Paragraphs.Count To 1 Step -1 sLett = aRng.Paragraphs(iPar).Range.Characters(1) If iPar > 1 Then sPrev = aRng.Paragraphs(iPar).Previous.Range.Characters(1) If sPrev <> sLett Or iPar = 1 Then aRng.Paragraphs(iPar).Range.InsertBefore sLett & vbCr aRng.Paragraphs(iPar).Style = "BibloChar" 'the new paragraph End If Next iPar End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
|||
|
|||
![]()
Wow, Mr. Andrew
It works by 100% Thank you, That’s very kind of you I can’t thank you enough Thank you for your guidance and support I will forever be beholden to you Thank you, I really appreciate your help |
![]() |
Tags |
vba code, vba find and replace, word vba code |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
donpopo | Word | 2 | 11-11-2018 11:32 PM |
![]() |
village | Word | 3 | 07-20-2018 01:48 AM |
![]() |
qubie | Word | 1 | 11-30-2017 02:03 PM |
![]() |
cheech1981 | Word | 7 | 11-24-2017 12:50 PM |
![]() |
xiangwulu | Word | 4 | 10-31-2014 09:00 AM |