none
Split table in MS word at occurrence of specific character.

    Question

  • Hello, I'm new in word forum, do anybody know how to split table automatically, for example to treat certain letter in one column, *, as a table break, or to split at specific number of rows, I'm dealing with table with hundreds of rows, and splitting this one by one is very tedious job. I can add a column to the right and insert specific character in all rows of that column, but then I don't know to do. 

    Thank you

    Friday, September 27, 2013 10:02 AM

Answers

  • Here is a macro that will split a table at *. Place the insertion point anywhere in the table before running the macro.

    Sub SplitTableAtChar()
        Application.ScreenUpdating = False
        Selection.Tables(1).Select
        With Selection.Find
            .ClearFormatting
            .MatchWildcards = False
            .Forward = True
            .Wrap = wdFindStop
            .Text = "*" ' or whatever you want to use
            Do While .Execute
                Selection.SplitTable
                Selection.MoveDown Count:=2
            Loop
        End With
        Application.ScreenUpdating = True
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Ahmed Morsyy Friday, September 27, 2013 8:36 PM
    Friday, September 27, 2013 11:32 AM

All replies

  • Here is a macro that will split a table at *. Place the insertion point anywhere in the table before running the macro.

    Sub SplitTableAtChar()
        Application.ScreenUpdating = False
        Selection.Tables(1).Select
        With Selection.Find
            .ClearFormatting
            .MatchWildcards = False
            .Forward = True
            .Wrap = wdFindStop
            .Text = "*" ' or whatever you want to use
            Do While .Execute
                Selection.SplitTable
                Selection.MoveDown Count:=2
            Loop
        End With
        Application.ScreenUpdating = True
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by Ahmed Morsyy Friday, September 27, 2013 8:36 PM
    Friday, September 27, 2013 11:32 AM
  • Thank you Hans, that worked fine, but if there is nested table in the main table, it is not working.

    Another challenge is to cut these spiltted tables and past it in another main table, each splitted table in a new row.

    Thank you again.

    Friday, September 27, 2013 8:36 PM
  • I'm not a Word expert - those questions are beyond me. I'm sure someone will be able to help you with them.

    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Friday, September 27, 2013 9:37 PM
  • Thank you Hans. I remembered that the splitted tables are separated by paragraph line, so I can select the range of tables and paragraphs and convert text to table using the paragraphs as separator for the main table.

     
    Friday, September 27, 2013 10:13 PM
  • Hi Hans, The code is working well, it might be my office 2010 problem.
    Saturday, September 28, 2013 5:59 PM