How can I fix this exception when working with text finder and merged cells in a loop?

ⅰ亾dé卋堺 提交于 2020-05-17 07:06:42

问题


I have a textFinder command wrapped in a for-loop. I believe the issue is with textFinder, but the same error occurs when wrapping the same string I've asked textFinder to find in logger.log(). It runs fine on the first pass, but it returns this error in the second pass.

Exception: You can't perform a paste that partially intersects a merge.

There is no pasting going on here. The cells I'm looking for are merged, but it doesn't take issue with those in the first pass. I'm wondering if it just doesn't know what column to continue looking through, as the values it looks for are all in merged cells. Is there any way to work around this without unmerging the cells? I'm only trying to look at each row once.

  var ePos = eBoard.getCell(2, 1); // change 2 to match eRow start value
  // Initialize textFinder
  var findBlank = Editor.getRange(row1,col1,100).createTextFinder('**LEAVE THIS ROW BLANK**');
  var findMe = Editor.createTextFinder(ePos.getDisplayValue()).startFrom(eBoard.getCell(1,1));

  for (var eRow = 2; eRow <= (row2-row1); eRow++){
    ePos = eBoard.getCell(eRow, 1);

    Logger.log(ePos.getDisplayValue()) //<--- error HERE

    // get the next range of members
    var topHold = findMe.findNext().getRow() + 1; // <--- error HERE
    var botHold = findBlank.findNext().getRow() - 1; // <--- error HERE
    var directors = Editor.getRange(topHold,1,(botHold - topHold + 1),3);
  }

来源:https://stackoverflow.com/questions/61741881/how-can-i-fix-this-exception-when-working-with-text-finder-and-merged-cells-in-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!