#1
|
|||
|
|||
Looking for Help to Create a Macro (Sort)
Hi all,
I have a document with a list of multiple choices with their answers (See sample below). 1. Under the NIA of the UCCA, let’s do the following: a. Nothing b. Do nothing c. Do nothing nothing nothing d. Do something Answer (B) is correct. Under the NIA of the UCC…. Answer (A) is incorrect. Under the NIA of the UCCA… Answer (C) is incorrect. Under the NIA of the UCCA… Answer (D) is incorrect. Under the NIA of the UCCA… As you can see the order of the answer choices sometimes (in my document) is not listed in the right order (a, b, c, and d) What I'm looking for is a macro that will sort the answer choices automatically in the following order: Answer (A) is incorrect. Under the NIA of the UCCA… Answer (B) is correct. Under the NIA of the UCC…. Answer (C) is incorrect. Under the NIA of the UCCA… Answer (D) is incorrect. Under the NIA of the UCCA… Therefore, the final output will be something as follows (the question followed by the answer choices in alphabetical order): 1. Under the NIA of the UCCA, let’s do the following: a. Nothing b. Do nothing c. Do nothing nothing nothing d. Do something Answer (A) is incorrect. Under the NIA of the UCCA… Answer (B) is correct. Under the NIA of the UCC…. Answer (C) is incorrect. Under the NIA of the UCCA… Answer (D) is incorrect. Under the NIA of the UCCA… Your assistance is appreciated. Thanks in advance for your great support. rsrasc |
#2
|
|||
|
|||
Unless you are masochistic or have somehow marked the text that you want sorted in a way that Word can recognize mechanically, you do not want a macro. You could spend days trying to develop a macro and not have something that is useful.
Select the text you want sorted and use the sort button on the home ribbon. |
#3
|
|||
|
|||
Thanks Mr. Kenyon for your reply. Bottom line, I will try to follow your advise if there are no other options, especially when you have over 150 multiple choice questions in that format. No a good idea but feasible!!!!
|
#4
|
|||
|
|||
The thing is, you want only certain text sorted, in groups. How will you tell the macro where a group begins and ends that is quicker than doing the sort through the interface? If that is already in place, you could do something. Otherwise, marking the text will not be any easier than sorting it.
|
#5
|
||||
|
||||
Try:
Code:
Sub Demo() Application.ScreenUpdating = False With ActiveDocument.Range .InsertParagraphAfter With .Find .ClearFormatting .Replacement.ClearFormatting .Text = "Answer \([A-E]\)[!^13]@^13" .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Format = False .MatchWildcards = True .Execute End With Do While .Find.Found Do While Left(.Paragraphs.Last.Next.Range.Text, 10) Like "Answer ([A-E])" .End = .Paragraphs.Last.Next.Range.End Loop .Sort .Collapse wdCollapseEnd .Find.Execute Loop End With With ActiveDocument.Range.Characters.Last While .Previous.Text = vbCr .Previous.Text = vbNullString Wend End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Hi Mr. Edstein,
Please consider this done. It's working great! Thank you for your assistance and cooperation. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Macro to create list of acronyms | lsmcal1984 | Word | 3 | 09-04-2013 07:33 AM |
Macro to conditionally create or go to worksheet | Reinaldo123 | Excel Programming | 1 | 07-06-2012 07:23 AM |
Sort table using macro | saslotteroy | Word VBA | 2 | 09-15-2011 02:41 PM |
Generic range for custom sort macro? | tswiers | Excel Programming | 2 | 08-11-2011 02:40 AM |
Create Custom menu using a macro | twnty2 | PowerPoint | 0 | 06-29-2011 04:26 PM |