VBA merge and unmerge according to if statement <p><strong>Example Image</strong> <a href="https://i.stack.imgur.com/qaX22.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qaX22.png" alt="enter image description here"></a></p> <p>I am having an issue with merging data in excel using VBA.</p> <p>Basically, I would like every cell row to be the same size and when a cell matches with a specific name, I want certain cells (specific 2 sets of rows preceding the name) to merge and center while others just merge across but that way some cells in the column have one number while others have a percentage and fraction as seen in this picture example above.</p> <p>I'm wondering if offset could be useful here as well?</p> <p>Here is some pseudo ish code to give you an idea: basically, if a cell in the A range matches a color (or whatever I put), then we want to merge and center two rows of cells and the 3 columns. Else if the cell in the A range matches a name (or whatever I put), then leave the cells separate but merge across maybe. </p> <pre><code>sub example1() if (cell in A range) = "red", "orange", "yellow", "green", "blue", then offset ( , 1) and merge&amp;center else if (cell in A range) = "sarah", "mark", "bob", "steve", "Brittany", then offset (, 1) and leavealone or merge just across end if end sub </code></pre>