Condition for Page Break

  • VBA Solution

    Hi, Andrey, and welcome to the site.

    I don't know of a way to do what you want through formatting. I do have a macro that will do it for you ...

    This macro looks for the word "Hello" (by itself, if you want it to find "Hello, World" or "Hello, Bob" and treat them the same, the code would require modification) in the working cells in Column A:A and, when found, inserts a PageBreak at that point.

    You can look up elsewhere on this site and find out how to paste code into a module.


  • hi, my case is : for everything the word= " Register", needed insert a page break, what ? the document header, is initiate " Register", consider spaces...
    treat the text document imported, format no appropriate ...

  • Hi, Andrey

    This modified code addresses the 'Register' issue you mentioned. For any cell in A:A that contains the full word 'Register' (wherever it appears in the cell), there will be a page break inserted. (Notice that this won't insert a page break for 'registration', or 'registry', but it will insert a break for 'Register', 'register', 'REGISTER', 'registers', 'registering', etc.)

    The code also resolves the issue you mailed me about, where an error message was generated because you had no existing page breaks installed. I should have tested for that. (And it's okay to point out errors in the public posting; other people may pick up code here from time to time, and if you already know it generates an error, they'd want to know also. I appreciate your apparent concern for my sensitivity in this regard.)


Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!