title: Google sheets: automatically merge identical cells
body: <p>I am trying to merge cells that are vertically adjacent and have identical values. </p>
  
  <pre><code>|"X"|         |"X"|
  |"X"|   ---&gt;  |   |
  |"X"|         |   | (merged)
  </code></pre>
  
  <p>I am making a time-tracking sheet and to have similar activities merged would be awesome
  <a href="https://i.stack.imgur.com/QHQup.png" rel="nofollow noreferrer">example image from my sheet</a>
  (So, "sleep" would be merged into one big block, and so would "tracking this sheet")</p>
  
  <p>I only want to merge cells vertically</p>
  
  <p>(also, I am operating only in the range of B26: H121)</p>
  
  <p>I have tried to work with some existing code on stackoverflow for this — <a href="https://stackoverflow.com/questions/53780869/google-sheets-horizontal-merge-identical-cells-in-single-row">Google Sheets - Horizontal merge identical cells in single row</a> and <a href="https://stackoverflow.com/questions/49212749/merge-cells-with-same-words">Merge cells with same words</a> — but I haven't been able to get anything to work. Maybe it's because I don't know javascript haha.</p>
  
  <p>———</p>
  
  <p>Also one last thing, if possible, I want to have someway of storing how large a merged cell is. (In the picture above it would be 16 and 4 for sleep and tracking this sheet, respectively.) This would allow me to track the time on any particular task when the cells are merged. (Maybe store this number in a note attached to the cell?)</p>
  
  <p>Please help,
  Paul</p>