# Merged cells 'No node at given position' error

**URL:** <https://discuss.prosemirror.net/t/merged-cells-no-node-at-given-position-error/4332>\
**Category:** Uncategorized\
**Created:** [January 12, 2022, 5:36pm UTC](https://discuss.prosemirror.net/t/merged-cells-no-node-at-given-position-error/4332 "2022-01-12T17:36:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremy](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/jeremy/32/2554_2.png) [@jeremy](https://discuss.prosemirror.net/u/jeremy)\
**Post date:** [January 12, 2022, 5:36pm UTC](https://discuss.prosemirror.net/t/merged-cells-no-node-at-given-position-error/4332/1 "2022-01-12T17:36:15Z")

</div>

Hello, I wrote some code to style the first two cells of a table. In a regular table, styling works fine. But when I merge cells, I get a `RangeError: 'No node at given position'` error. I’ve been trying to solve this for a day and a half and still not getting anywhere. I don’t understand why it can’t find the second node. Please help. Thanks ![ezgif.com-gif-maker (1)](https://discuss.prosemirror.net/uploads/secondsite/original/2X/a/aa2e1dcbf5ccd6ae5331119a503669de80efeb06.gif)

```auto
console.log('tableStartPos: ', tableStartPos, 'tableEndPos', tableEndPos)
if (tableStartPos && tableEndPos)
  for (let pos = tableStartPos; pos < tableEndPos; pos++)
    if (
      state.doc.nodeAt(pos)?.type.name === 'tableHeader' ||
      state.doc.nodeAt(pos)?.type.name === 'tableCell'
    ) {
      count++
      console.log('About to style node: ', this.editor.state.doc.nodeAt(pos), 'Pos: ', pos)
      this.editor.view.dispatch(this.editor.view.state.tr.setNodeMarkup(pos, undefined, {
        //style: newStyles,
        style: 'border: 3px dashed #0100ff; ',
      }))
      console.log('Styled node', this.editor.view.state.doc.nodeAt(pos), 'Pos: ', pos)
      if (count === 2)
        break
    }

```
