Consulting

Results 1 to 12 of 12

Thread: Find the paragraph between Question 1 and Question 2?

  1. #1
    VBAX Regular
    Joined
    Jan 2021
    Posts
    9
    Location

    Post Find the paragraph between Question 1 and Question 2?

    Before
    Question 1. What your name ?
    A. My name Kh. B. My name T
    C. My name Q D. My name G
    Question 2. How are you?
    A. I'm fine.
    B. I'm cold
    C. I'm hot
    D. I'm so so.
    I want ...
    After
    Question 1. What your name ?
    A. My name Kh. B. My name T
    C. My name Q D. My name G
    Tks

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Your Before & After for Question 1 look the same to me. To reformat all questions as per Question 1 you could use a wildcard Find/Replace, where:
    Find = (Question [0-9]*\?^13A. *)^13(B. *^13C. *)^13(D. *^13)
    Replace = \1 \2 \3
    Alternatively, if you simply want to delete Questions formatted like Question 2, simply leave the Replace expression empty.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    Jan 2021
    Posts
    9
    Location
    please detail !

    Quote Originally Posted by macropod View Post
    Your Before & After for Question 1 look the same to me. To reformat all questions as per Question 1 you could use a wildcard Find/Replace, where:
    Find = (Question [0-9]*\?^13A. *)^13(B. *^13C. *)^13(D. *^13)
    Replace = \1 \2 \3
    Alternatively, if you simply want to delete Questions formatted like Question 2, simply leave the Replace expression empty.



    My idea, take question 1, then copy it to another page! Tks
    Last edited by macropod; 01-31-2021 at 01:14 PM.

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Well, that isn't what your first post asked!

    Kindly explain exactly what you're trying do achieve. After all, what you're now saying can be dome by simply copying & pasting Question 1 and its answers.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    VBAX Regular
    Joined
    Jan 2021
    Posts
    9
    Location
    What i want is format all
    Question....
    After
    Question 1. What your name ?
    A. My name Kh.
    B. My name T
    C. My name Q
    D. My name G
    Question 2. How are you?
    A. I'm fine.
    B. I'm cold
    C. I'm hot
    D. I'm so so.
    (Poor English hope for sympathy)

  6. #6
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    That really does not address what I wrote in post #4.

    Now, however, your Question 1 and its answers are formatted differently from what they were in Post #1.

    I still have no idea what you're trying to achieve.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  7. #7
    VBAX Regular
    Joined
    Jan 2021
    Posts
    9
    Location
    Quote Originally Posted by macropod View Post
    That really does not address what I wrote in post #4.

    Now, however, your Question 1 and its answers are formatted differently from what they were in Post #1.

    I still have no idea what you're trying to achieve.
    So Sorry, i want format all question same this
    Before
    Question 1. What your name ?
    A. My name Kh. B. My name T
    C. My name Q D. My name G
    Question 2. How are you?
    A. I'm fine.
    B. I'm cold
    C. I'm hot
    D. I'm so so.
    Questio 3. Whers are you from?
    A. Answer 1. B. Answer 2 C. Answer 3 D. Answer 4

    After
    Question 1. What your name ?
    A. My name Kh.
    B. My name T
    C. My name Q
    D. My name G
    Question 2. How are you?
    A. I'm fine.
    B. I'm cold
    C. I'm hot
    D. I'm so so.
    Questio 3. Whers are you from?
    A. Answer 1.
    B. Answer 2
    C. Answer 3
    D. Answer 4

    Help me! Tks

  8. #8
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    To reformat all questions as per Question 2 you could use a wildcard Find/Replace, where:
    Find = (Question [0-9]*\?^13A. *)[ ^13](B. *)[ ^13](C. *)[ ^13](D. *^13)
    Replace = \1^p\2^p\3^p\4
    Last edited by macropod; 02-01-2021 at 01:54 PM.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  9. #9
    VBAX Regular
    Joined
    Jan 2021
    Posts
    9
    Location
    Quote Originally Posted by macropod View Post
    To reformat all questions as per Question 2 you could use a wildcard Find/Replace, where:
    Find = (Question [0-9]*\?^13A. *)[ ^13](B. *)[ ^13](C. *)[ ^13](D. *^13)
    Replace = \1^p\2^p\3^p\4
    help!

    Sub Macro()
    With ActiveDocument.Content.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchWildcards = True
    .Text = "(Question [0-9]*\?^13A. *)[ ^13](B. *)[ ^13](C. *)[ ^13](D. *^13)"
    .Replacement.Text = "\1^p\2^p\3^p\4"
    .Execute Replace:=wdReplaceAll
    End With
    End Sub

  10. #10
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Help with what? The F/R works on the sample text in post #7.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  11. #11
    VBAX Regular
    Joined
    Jan 2021
    Posts
    9
    Location
    Quote Originally Posted by macropod View Post
    Help with what? The F/R works on the sample text in post #7.
    Code no run

  12. #12
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Your code works for me...
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •