---
title: "Unmerge cells in Excel for .csv export"
canonical_url: "https://codex.republic.se/development/articles/unmerge-cells-in-excel-for-csv-export"
section: "Pages"
---

# Unmerge cells in Excel for .csv export

---

1. Open your sheet
2. **Alt + F11**
3. Insert —&gt; Module
4. Enter the code

    ```vbnet
    Sub activesheet_unmerge()
      Dim c As Range
      Dim c2 As Range
      Dim rMergeArea As Range
      Dim vMergeValue As Variant
      For Each c In ActiveSheet.UsedRange
        If c.MergeCells Then
          Set rMergeArea = c.MergeArea
          vMergeValue = c.Value
          rMergeArea.unmerge
          For Each c2 In rMergeArea
            c2.Value = vMergeValue
          Next
        End If
      Next
    End Sub

    ```
5. **Run**
