Excel Guides

Selecting Columns in VBA when Cells are Merged in Excel

When cells are merged in Excel, the process of selecting columns can be a bit more difficult than usual. This is because, when cells are merged, they are technically still separate cells. As a result, you have to take a few extra steps to select the columns you want to work with in VBA.

The first step is to unmerge the cells. You can do this by right-clicking on the merged cells and selecting "Unmerge Cells" from the drop-down menu. Once the cells are unmerged, you can proceed with selecting the columns as you normally would.

To select multiple columns, you can hold down the "Shift" key and click on the first and last column you want to select. Alternatively, you can click on the first column, hold down the "Shift" key, and then use the arrow keys to select additional columns. Once you have the columns selected, you can release the "Shift" key.

If you want to select non-adjacent columns, you can do so by holding down the "Ctrl" key and clicking on each individual column you want to select. Again, once you have all of the desired columns selected, you can release the "Ctrl" key.

Once you have the columns selected that you want to work with in VBA, you can proceed with your code as usual. Keep in mind that if you make any changes to your data that would cause the cells to be merged again (such as inserting or deleting rows or columns), you will need to unmerge them again before proceeding.

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.