Error: Unmatched begin/end statement

This article is complemented by the sample form here.

This error appears when validating a spreadsheet form design, usually when you are uploading it to the server, either as a new form or as an update to an already deployed form design. The error means the form design has a group or a repeat group that begins, but does not end, or a group that ends, but does not begin.


Error uploading form: The form definition could not be processed:

Unmatched begin statement: group

Alternative error message:

Error uploading form: The form definition could not be processed:

[row : X] Unmatched end statement. Previous control type: group, Control type: repeat

The begin and end points of groups in a form design must be equal in number in order for a form to validate. Even when they are equal, they must be logically paired in the design in order for the design to validate.

The second error message above is more commonly caused by an interrupted group or repeat group. For more information, check out part 3 below, but it is still a good idea to first perform parts 1 and 2.

If you work only in the online form designer, at some point the design must have been edited offline in the spreadsheet template. You can also use the instructions below to resolve.


These steps are for working in Microsoft Excel, and may be slightly different if working in Google Sheets.

Tip: As you are creating your form, give your end group and end repeat rows names that match the names of the groups they begin. While these are not required, they can make future troubleshooting a lot easier.

Part 1: Check for disabled rows

Check if you accidentally disabled any begin group, end group, begin repeat, or end repeat rows. For example, take a look at this screenshot:


Even though there is one begin group and one end group, the end group row is disabled, so it will not be counted when the form definition is being verified. Check to make sure that any needed group-related rows are not disabled.

The disabled field property is optional. If you'd like, delete this column from the survey sheet if you're having any trouble with it.

Part 2: Count number of begins and ends

Next, you will need to count the number of begin group, begin repeat, etc rows. You can do this manually, but it is much easier to use spreadsheet formulas.

  1. Note the column letter with the type column header. This is usually column A.
  2. Add a new sheet to the spreadsheet.
  3. Optional: In this new sheet, add headers for begin group, begin repeat, end group, and end repeat.
  4. In four of the cells, add a formula that uses the COUNTIF() function to count the number of instances of each group-related row type. For example, use this formula to count the number of begin group types there are:
    =COUNTIF(survey!$A:$A,"begin group")

    If applicable, replace "A" with the column letter noted in step 1.

  5. Use these numbers to determine what needs to be added or removed. For example, if there is one more end repeat than there is begin repeat, either add a begin repeat where it is needed, or remove an end repeat row.

Keep in mind that this will not find group beginning or end point indicators (e.g. "begin group", "end repeat", etc) where there are leading or trailing spaces. For example, it will not count "begin group ", since there is a trailing space. If you suspect this is causing a counting issue, you can use a formula that uses regular expressions instead, like this:

=COUNTA(FILTER(survey!$A2:A, REGEXMATCH(survey!$A2:A, "^ *begin group *$")))

Check out this post for more information.

Part 3: Check for interrupted groups

If there are no disabled group-related rows, and you have an even number of begins and ends for both groups and repeats, chances are a begin repeat was used when an end group should have been used, or vice-versa. In other words, a group was interrupted.

For example, take a look at these rows:


Here, the number of begin groups matches the number of end groups, and the number of begin repeats matches the number of end repeats, so what's the issue? If you look at row 146, the group "rep1" ends right in the middle of "group2". You cannot end a repeat until all groups started in that repeat group have been ended, and vice-versa. Either the end group on row 172 needs to be moved between rows 145 and 146, or the end repeat on row 146 needs to be moved between rows 172 and 173.

This is a tricky error that can take some time to properly resolve. First, check the error message, since it usually states which row the error is on. If you have trouble finding where the group was interrupted, follow these steps:

  1. Save a copy of your form definition. Continue these steps within that copy.
  2. Create a filter so only group-related rows are shown (see below).
  3. Find a group or repeat group that has no group-related rows inside of it (e.g. no begin repeat, etc).
  4. Delete that group. In other words, delete the begin row, the end row, and everything in-between (make sure everything in-between has no group-related rows).
  5. Repeat steps 3-4 until the form has been simplified enough so you can find the interrupting row.
  6. Go back to the original form, and use what you have found to delete or move the row that is causing the issue.

For example, look at these screenshots:

1. Select "begin group" and "end group" rows that have no group-related rows between them.
2. Right-click and delete those rows.
3. It is now easier to see that an "end group" is used on row 182 when an "end repeat" should be used first.

After deleting rows 177-183 (which have no group-related rows in-between), it is much easier to see that the end group for "group3" on what is now row 182 is causing the issue. This is because there is a begin repeat right before it, and "group3" cannot be ended until all repeat groups started inside it, namely "rep2", have been ended.

Tip: You don't need to upload a form design to your server to validate it. SurveyCTO Desktop can do this for you offline.

Creating a filter

Check out the Microsoft documentation to learn more.

While not required, troubleshooting this error can be a lot easier when only the group-related rows are being shown. Follow these steps to set up your filter:

  1. Select the type column, likely column A. All cells in that column should now be highlighted.
  2. Go to the Data tab of Excel.
  3. Select the Filter button.
  4. In cell A1, an arrow will appear to the right of type. Select that arrow.
  5. For the dropdown that says Choose one, select contains.
  6. In the box with the checkmarks, uncheck all boxes except begin group, begin repeat, end group, and end repeat.


Example and exercise

We have prepared an example you can try. This example is a simple version of this error, so you can use it for practice before attempting to troubleshoot the error in your own form.

Save the sample form (link at the top of this article) to your own computer or Google Drive. If you try to upload it to your server, you will get the Unmatched error. Follow the steps above to try and find where the error is.


  • Check the counting sheet, where COUNTIF() formulas have already been set up.
  • Remember that a group cannot end in the middle of another group.
  • Check the notes column, which describe each group.

Click here for the solution.


Please sign in to leave a comment.