+ Reply to Thread
Results 1 to 10 of 10

Getting run-time error 5631 no merge document or no option match your query option

  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Getting run-time error 5631 no merge document or no option match your query option

    Hi friends,

    If there is remark ‘Send’ in column ‘W’ ‘REMARK L’ then I want to generate letter
    If there is remark ‘Sent’ in column ‘W’ ‘REMARK L’ then I don’t want to generate letter

    The problem is …
    If there is one or more ‘Send’ remarks in column ‘W’ ‘REMARK L’ column then it works fine but if there is ‘Sent’ remark in column ‘W’ ‘REMARK L’ then I get a error 5631 ‘no merge document of the record didn’t match query option’

    Requirement …
    If there is no ‘Send’ remark in column ‘W’ ‘REMARK L’ and by mistake the user runs the macro then I wants to pop up warning message and exit sub.

    If there is one or more ‘Send’ remarks in column ‘W’ then it works fine. With the kind guidance of Paul I have develop this macro.

    Please Login or Register  to view this content.
    Any help will be highly appreciated.

    Thanking you in anticipation.
    Sincerely,

    mso3

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Getting run-time error 5631 no merge document or no option match your query option

    You have two different macros there. Which one are you using?

    Also, do you have a pathological dislike for properly-structured code? I posted code with an intelligible structure in your other thread and now you're posting it back with a messed-up structure that looks like your dog dragged it around the neighbourhood for a few days.

    As for the problem itself, you could obviate that by using Excel's 'Find' method to check whether there are any 'Send' records in the nominated range.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting run-time error 5631 no merge document or no option match your query option

    Hi Paul,

    Sorry! I like the code you provided very well and using it. Please don’t mind. After exploring; I observed a error 5631 if there is no ‘Send’ remark in column ‘W’. So I thought to solve. Yes, it was the wrong attempt to solve the problem. As per your guidance now I used ‘Find’ method and amended the code. It’s running without error as per requirement. Please see and suggest me if anything is wrong. Is it a right method of use ‘Find’ method?

    The amended code is:

    Please Login or Register  to view this content.
    Sorry for trouble.

    Thanking you,

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Getting run-time error 5631 no merge document or no option match your query option

    That's not how I'd implement the Find. Your implementation looks for 'Send' anywhere in column W, whereas you're only concerned with whether 'Send' occurs in the record range chosen by the user. Therefore your Find should occur after the user has input the record details and be limited to that range. For example, if the user chooses to merge records 100-200, your find should check W101-W201.

  5. #5
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting run-time error 5631 no merge document or no option match your query option

    Hi Paul,

    Thank you.

    Like this?
    Please Login or Register  to view this content.
    Is this correct or not?

    Thank you and have a nice time.

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Getting run-time error 5631 no merge document or no option match your query option

    No, because you're still not testing the nominated range; you're still testing the whole column.

  7. #7
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting run-time error 5631 no merge document or no option match your query option

    Hi Paul,

    Oops! Is it correct now? If not correct me please.

    Please Login or Register  to view this content.
    Thanking you,

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Getting run-time error 5631 no merge document or no option match your query option

    There's no point continually asking me if things are right when you've clearly ignored what I wrote in post #4. This code sequence:
    Set rng1 = Range("W:W").Find(strSearch, , xlValues, xlWhole)
    x = InputBox("What is the first record to merge?", , 1)
    y = InputBox("What is the last record to merge?", , lRec)
    can never test the nominated range, because:
    1. You don't even get the nominated range until after rng1 is set; and, because of this
    2. You don't (and can't) supply the nominated rows for the Range parameter.

  9. #9
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: Getting run-time error 5631 no merge document or no option match your query option

    Hi Paul,

    Sorry! Due to my misunderstanding I didn’t follow your instruction. Now I understood that the range1 should be the value of inputbox X and Y. However, I don’t know how to set it. I was trying it but in vain.

    Set rng1 = inputbox(“X”).value:inputbox(“Y”).value).Find(strSearch, , xlValues, xlWhole)

    Please suggest me the correct way to set it.

    Thanking you,

  10. #10
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Getting run-time error 5631 no merge document or no option match your query option

    Quote Originally Posted by mso3 View Post
    Please suggest me the correct way to set it.
    I already did that - in post #4!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Group option and calculated field option greyed out on pivot table
    By KevinMolina in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-16-2015, 05:00 PM
  2. Replies: 2
    Last Post: 08-15-2013, 12:25 PM
  3. [SOLVED] Multiple option buttons - Need VBA to disable second group of option buttns based on respo
    By ex123 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-19-2013, 03:30 AM
  4. Creating Search Option on Document
    By cruiser102 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-29-2009, 02:50 PM
  5. mail merge, option to not choose closest match from active directory?
    By kuraitori in forum Word Formatting & General
    Replies: 0
    Last Post: 11-25-2009, 08:38 PM
  6. Replies: 2
    Last Post: 06-26-2007, 02:55 PM
  7. Option Box Run Time Error Cell Locked
    By harksteve in forum Excel General
    Replies: 3
    Last Post: 01-16-2006, 11:00 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1