Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-15-2014, 05:19 AM
rsrasc rsrasc is offline Looking for Help to Create a Macro (Sort) Windows 7 64bit Looking for Help to Create a Macro (Sort) Office 2010 64bit
Competent Performer
Looking for Help to Create a Macro (Sort)
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 04-15-2014, 05:31 AM
Charles Kenyon Charles Kenyon is offline Looking for Help to Create a Macro (Sort) Windows 7 64bit Looking for Help to Create a Macro (Sort) Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Attached Images
File Type: png 00 deleteme.png (36.1 KB, 40 views)
Reply With Quote
  #3  
Old 04-15-2014, 06:28 AM
rsrasc rsrasc is offline Looking for Help to Create a Macro (Sort) Windows 7 64bit Looking for Help to Create a Macro (Sort) Office 2010 64bit
Competent Performer
Looking for Help to Create a Macro (Sort)
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

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!!!!
Reply With Quote
  #4  
Old 04-15-2014, 07:31 AM
Charles Kenyon Charles Kenyon is offline Looking for Help to Create a Macro (Sort) Windows 7 64bit Looking for Help to Create a Macro (Sort) Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,125
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #5  
Old 04-15-2014, 02:40 PM
macropod's Avatar
macropod macropod is offline Looking for Help to Create a Macro (Sort) Windows 7 32bit Looking for Help to Create a Macro (Sort) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #6  
Old 04-16-2014, 03:25 AM
rsrasc rsrasc is offline Looking for Help to Create a Macro (Sort) Windows 7 64bit Looking for Help to Create a Macro (Sort) Office 2010 64bit
Competent Performer
Looking for Help to Create a Macro (Sort)
 
Join Date: Mar 2014
Location: Germany
Posts: 148
rsrasc is on a distinguished road
Default

Hi Mr. Edstein,

Please consider this done. It's working great!

Thank you for your assistance and cooperation.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for Help to Create a Macro (Sort) 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
Looking for Help to Create a Macro (Sort) 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

Other Forums: Access Forums

All times are GMT -7. The time now is 08:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft